function pKlpruangan(){ var fields_klpruangan = RH.storeFields('idklpruangan','kdklpruangan','nmklpruangan','deskripsi'); var pageSize = 18; var ds_klpruangan = RH.JsonStore({ url : BASE_URL + 'klpruangan_controller/get_klpruangan', fields : fields_klpruangan, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_klpruangan = RH.searchComp({ id : 'sb_klpruangan', fields : ['kdklpruangan:Kode','nmklpruangan:Nama'], selected : 'nmklpruangan', store : ds_klpruangan }); // COLUMN MODEL var cm_klpruangan = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Kode',width: 100, dataIndex: 'kdklpruangan', sortable: true }, { header: 'Nama', width: 300, dataIndex: 'nmklpruangan', sortable: true }, { header: 'Deskripsi', width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_klpruangan = RH.GridPanel_T1({ ds: ds_klpruangan, cm: cm_klpruangan, singleSelect: true, searchComp: sb_klpruangan, allowAdd: true, fnAdd: fnAddklpRuangan, pageSize: pageSize, cellclick: onCellklpRuanganClick }); var fp_klpruangan = RH.GPContainer1({ title: 'Kelompok Ruangan', iconCls:'silk-house', gridPanel: gp_klpruangan, }); SET_PAGE_CONTENT(fp_klpruangan); /** FUNCTIONS */ function onCellklpRuanganClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditklpRuangan(grid, record)}); RH.DeleteClick(e, function(){fnDeleteklpRuangan(grid, record)}); } function reloadklpRuangan(){ ds_klpruangan.reload(); } function fnAddklpRuangan(){ var grid = gp_klpruangan; wEntryklpruangan(false, grid, null); } function fnEditklpRuangan(grid, record){ wEntryklpruangan(true, grid, record); } function fnDeleteklpRuangan(grid, record){ var url = BASE_URL + 'klpruangan_controller/delete_klpruangan'; var params = new Object({ idklpruangan : record.data['idklpruangan'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT KELOMPOK RUANGAN */ function wEntryklpruangan(isUpdate, grid, record){ var winTitle = 'Kelompok Ruangan ' + ((isUpdate)?'(Edit)':'(Tambah)'); /** FORM ENTRY/EDIT MATA-KULIAH */ var klpruangan_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.klpruangan', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 200, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.kdklpruangan', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmklpruangan', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveklpRuangan(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wklpRuangan.close(); } }] }); var wklpRuangan = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [klpruangan_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setklpRuanganForm(isUpdate, record); wklpRuangan.show(); /** FORM FUNCTIONS */ function setklpRuanganForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ RH.disableComp('tf.frm.kdklpruangan'); RH.setCompValue('tf.frm.kdklpruangan', record.data['kdklpruangan']); RH.setCompValue('tf.frm.nmklpruangan', record.data['nmklpruangan']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveklpRuangan(){ var idForm = 'frm.klpruangan'; var sUrl = BASE_URL +'klpruangan_controller/insert_klpruangan'; var sParams = new Object({ kdklpruangan : RH.getCompValue('tf.frm.kdklpruangan'), nmklpruangan : RH.getCompValue('tf.frm.nmklpruangan'), deskripsi : RH.getCompValue('ta.frm.deskripsi'), }); 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 +'klpruangan_controller/update_klpruangan'; sParams.idklpruangan = record.data['idklpruangan']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wklpRuangan, msgWait, msgSuccess, msgFail, msgInvalid); } }