function pTiperuangan(){ var fields_tpruangan = RH.storeFields('idtiperuangan','kdtiperuangan','nmtiperuangan'); var pageSize = 20; var ds_tpruangan = RH.JsonStore({ url : BASE_URL + 'tiperuangan_controller/get_tiperuangan', fields : fields_tpruangan, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_tpruangan = RH.searchComp({ id : 'sb_tpruangan', fields : ['kdtiperuangan:Kode Tipe Ruangan','nmtiperuangan:Nama Tipe Ruangan'], selected : 'nmtiperuangan', store : ds_tpruangan }); // COLUMN MODEL var cm_tpruangan = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode Tipe Ruangan'), width: 150, dataIndex: 'kdtiperuangan', sortable: true }, { header: RH.h3('Nama Tipe Ruangan'), width: 150, dataIndex: 'nmtiperuangan', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_tpruangan = RH.GridPanel_T1({ ds: ds_tpruangan, cm: cm_tpruangan, singleSelect: true, searchComp: sb_tpruangan, allowAdd: true, fnAdd: fnAddTpruangan, pageSize: pageSize, cellclick: onCellTpruanganClick }); var fp_tpruangan = RH.GPContainer1({ title: 'Tipe Ruangan', iconCls:'silk-house', gridPanel: gp_tpruangan, }); SET_PAGE_CONTENT(fp_tpruangan); /** FUNCTIONS */ function onCellTpruanganClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditTpruangan(grid, record)}); RH.DeleteClick(e, function(){fnDeleteTpruangan(grid, record)}); } function reloadTpkls(){ ds_tpruangan.reload(); } function fnAddTpruangan(){ var grid = gp_tpruangan; wEntryTpruangan(false, grid, null); } function fnEditTpruangan(grid, record){ wEntryTpruangan(true, grid, record); } function fnDeleteTpruangan(grid, record){ var url = BASE_URL + 'tiperuangan_controller/delete_tiperuangan'; var params = new Object({ idtiperuangan : record.data['idtiperuangan'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS SLTA */ function wEntryTpruangan(isUpdate, grid, record){ var winTitle = (isUpdate)?'Tipe Ruangan (Edit)':'Tipe Ruangan (Entry)'; /** DATA SOURCE GRUP JENIS SLTA */ /*var ds_grup = new Ext.data.JsonStore({ //static data fields: [{ name:'kode' }, { name:'nama' }], data: [ { "kode":"1","nama":"test1"}, { "kode":"2","nama":"test2"} ] });*/ /** FORM ENTRY/EDIT MATA-KULIAH */ var tpruangan_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.tpruangan', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 150, width: 400, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.idtiperuangan', fieldLabel: 'ID Tipe Ruangan', hidden: true, },{ id: 'tf.frm.kdtiperuangan', fieldLabel: 'Kode Tipe Ruangan', width: 200, allowBlank: false, },{ id: 'ta.frm.nmtiperuangan', fieldLabel: 'Nama Tipe Ruangan', width: 200, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveTpruangan(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wTpruangan.close(); } }] }); var wTpruangan = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [tpruangan_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setTpklsForm(isUpdate, record); wTpruangan.show(); /** FORM FUNCTIONS */ function setTpklsForm(isUpdate, record){ //var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnsslta'); RH.setCompValue('tf.frm.idtiperuangan', record.data['idtiperuangan']); RH.setCompValue('tf.frm.kdtiperuangan', record.data['kdtiperuangan']); RH.setCompValue('ta.frm.nmtiperuangan', record.data['nmtiperuangan']); return; } } } function fnSaveTpruangan(){ var idForm = 'frm.tpruangan'; var sUrl = BASE_URL +'tiperuangan_controller/insert_tiperuangan'; var sParams = new Object({ //kdjnsslta : RH.getCompValue('tf.frm.kdjnsslta'), kdtiperuangan : RH.getCompValue('tf.frm.kdtiperuangan'), nmtiperuangan : RH.getCompValue('ta.frm.nmtiperuangan'), }); 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 +'tiperuangan_controller/update_tiperuangan'; sParams.idtiperuangan = record.data['idtiperuangan']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wTpruangan, msgWait, msgSuccess, msgFail, msgInvalid); } }