function pJUsm(){ var fields_jusm = RH.storeFields('idjnsusm','kdjnsusm','nmjnsusm','deskripsi'); /** store */ var pageSize = 18; var ds_jusm = RH.JsonStore({ url : BASE_URL + 'jusm_controller/get_jusm', fields : fields_jusm, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jusm = RH.searchComp({ id : 'sb_jusm', fields : ['kdjnsusm:Kode','nmjnsusm:Nama'], selected : 'nmjnsusm', store : ds_jusm }); var cm_jusm = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'idjnsusm', dataIndex: 'idjnsusm', hidden: true }, { header: 'Kode',width: 80, dataIndex: 'kdjnsusm', sortable: true }, { header: 'Nama', width: 200, dataIndex: 'nmjnsusm', sortable: true }, { header: 'Deskripsi', width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jusm = RH.GridPanel_T1({ ds: ds_jusm, cm: cm_jusm, singleSelect: true, searchComp: sb_jusm, allowAdd: true, fnAdd: fnAddJUsm, pageSize: pageSize, cellclick: onCellJUsmClick }); var fp_jusm = new Ext.Panel({ xtype: 'panel', title: 'Jenis USM', iconCls:'silk-house', buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, layout: 'fit', waitMsg: 'Waiting...', maskDisabled: false, monitorValid: true, frame: true, items: [{ xtype: 'panel', layout:'fit', items: [gp_jusm], }], }); SET_PAGE_CONTENT(fp_jusm); /** FUNCTIONS */ function onCellJUsmClick(grid, rowIndex, columnIndex, e) { var t = e.getTarget(); var record = grid.getStore().getAt(rowIndex); // Get the Record //var columnId = grid.getColumnModel().getId(columnIndex); // Get column id var sm = grid.getSelectionModel(); var sel = sm.getSelected(); if (t.className == 'imgEdit') { fnEditJkelas(grid, record); return true; } if (t.className == 'imgDelete') { fnDeleteJkelas(grid, record); return true; } return false; } function reloadJkelas(){ ds_jusm.reload(); } function fnAddJUsm(){ var grid = gp_jusm; wform_jusm(false, grid, null); } function fnEditJkelas(grid, record){ wform_jusm(true, grid, record); } function fnDeleteJkelas(grid, record){ var url = BASE_URL + 'jusm_controller/delete_jusm'; var params = new Object({ idjnsusm : record.data['idjnsusm'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS USM */ function wform_jusm(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis USM (Edit)':'Jenis USM (Entry)'; /** THE FORM */ var jusm_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jusm', buttonAlign: 'left', labelWidth: 100, 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.kdjnsusm', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmjnsusm', fieldLabel: 'Jenis Kelas', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJUsm(); } }, { text: 'Kembali', iconCls:'', handler: function() { wJUsm.close(); } }] }); var wJUsm = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jusm_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJUsmForm(isUpdate, record); wJUsm.show(); /** FORM FUNCTIONS */ function setJUsmForm(isUpdate, record){ if(isUpdate){ if(record != null){ //Ext.getCmp('tf.frm.kdjnsusm').disable(); RH.setCompValue('tf.frm.kdjnsusm', record.data['kdjnsusm']); RH.setCompValue('tf.frm.nmjnsusm', record.data['nmjnsusm']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveJUsm(){ var idForm = 'frm.jusm'; var sUrl = BASE_URL +'jusm_controller/insert_jusm'; var sParams = getInsertJUsmParams(); 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 +'jusm_controller/update_jusm'; sParams.idjnsusm = record.data['idjnsusm']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJUsm, msgWait, msgSuccess, msgFail, msgInvalid); } // GET PARAMETERS FOR INSERT/UPDATE function getInsertJUsmParams(){ return new Object({ kdjnsusm : RH.getCompValue('tf.frm.kdjnsusm'), nmjnsusm : RH.getCompValue('tf.frm.nmjnsusm'), deskripsi : RH.getCompValue('ta.frm.deskripsi'), }); } }