function pFakultas(){ var fields_fakultas = RH.storeFields('kdfakultas','kdpt','nmfakultas','nmfakultasskt','deskripsi'); var pageSize = 18; var ds_fakultas = RH.JsonStore({ url : BASE_URL + 'fakultas_controller/get_fakultas', fields : fields_fakultas, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_fakultas = RH.searchComp({ fields : ['kdfakultas:Kode','nmfakultas:Nama','nmfakultasskt:Singkatan'], selected : 'nmfakultas', store : ds_fakultas }); // COLUMN MODEL var cm_fakultas = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Kode',width: 80, dataIndex: 'kdfakultas', sortable: true }, { header: 'Nama', width: 300, dataIndex: 'nmfakultas', sortable: true }, { header: 'Singkatan', width: 200, dataIndex: 'nmfakultasskt', sortable: true }, { header: 'Deskripsi', width: 300, dataIndex: 'deskripsi', sortable: true, }, RH.EditColumn(), RH.DeleteColumn() ] ); var gp_fakultas = RH.GridPanel_T1({ ds: ds_fakultas, cm: cm_fakultas, singleSelect: true, searchComp: sb_fakultas, allowAdd: true, fnAdd: fnAddFakultas, pageSize: pageSize, cellclick: onCellFakultasClick }); //var fp_fakultas = new Ext.form.FormPanel({ var fp_fakultas = RH.GPContainer1({ title: 'Fakultas', iconCls:'silk-house', gridPanel: gp_fakultas, }); SET_PAGE_CONTENT(fp_fakultas); /** FUNCTIONS */ function onCellFakultasClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditFakultas(grid, record)}); RH.DeleteClick(e, function(){fnDeleteFakultas(grid, record)}); } function reloadFakultas(){ ds_fakultas.reload(); } function fnAddFakultas(){ var grid = gp_fakultas; wform_fakultas(false, grid, null); } function fnEditFakultas(grid, record){ wform_fakultas(true, grid, record); } function fnDeleteFakultas(grid, record){ var url = BASE_URL + 'fakultas_controller/delete_fakultas'; var params = new Object({ kdfakultas : record.data['kdfakultas'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT RUANGAN */ function wform_fakultas(isUpdate, grid, record){ var winTitle = (isUpdate)?'Fakultas (Edit)':'Fakultas (Entry)'; /** DATA STORE */ var ds_pt = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_pt ', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "kdpt" }, { name: "nmpt" }] }); //----------------------------------- var fakultas_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.fakultas', buttonAlign: 'left', labelWidth: 110, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 250, width: 450, layout: 'form', frame: false, defaultType:'textfield', items: [ { xtype: 'combo', id: 'cb.frm.kdpt', fieldLabel: 'Perguruan Tinggi', allowBlank: false, editable:false, store: ds_pt, triggerAction: 'all', valueField: 'kdpt', displayField: 'nmpt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, },{ id: 'tf.frm.kdfakultas', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmfakultas', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ id: 'tf.frm.nmfakultasskt', fieldLabel: 'Singkatan', width: 300, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveFakultas(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wFakultas.close(); } }] }); var wFakultas = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [fakultas_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setFakultasForm(isUpdate, record); wFakultas.show(); /** FORM FUNCTIONS */ function setFakultasForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ Ext.getCmp('tf.frm.kdfakultas').disable(); RH.setCompValue('tf.frm.kdfakultas', record.data['kdfakultas']); RH.setCompValue('cb.frm.kdpt', record.data['kdpt']); RH.setCompValue('tf.frm.nmfakultas', record.data['nmfakultas']); RH.setCompValue('tf.frm.nmfakultasskt', record.data['nmfakultasskt']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveFakultas(){ var idForm = 'frm.fakultas'; var sUrl = BASE_URL +'fakultas_controller/insert_fakultas'; var sParams = getInsertFakultasParams(); var msgWait = 'Tunggu, sedang proses menyimpan...'; var msgSuccess = 'Tambah data berhasil'; var msgFail = 'Tambah data gagal'; var msgInvalid = 'Data belum valid (data primer belum terisi)!'; if(isUpdate){ sUrl = BASE_URL +'fakultas_controller/update_fakultas'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wFakultas, msgWait, msgSuccess, msgFail, msgInvalid); //wfakultas.close(); } // GET PARAMETERS FOR INSERT/UPDATE function getInsertFakultasParams(){ return new Object({ kdfakultas : RH.getCompValue('tf.frm.kdfakultas'), kdpt : RH.getCompValue('cb.frm.kdpt'), nmfakultas : RH.getCompValue('tf.frm.nmfakultas'), nmfakultasskt : RH.getCompValue('tf.frm.nmfakultasskt'), deskripsi : RH.getCompValue('ta.frm.deskripsi'), }); } }