function pJbiaya(){ var fields_jbiaya = RH.storeFields('idjnsbiaya','kdjnsbiaya','nmjnsbiaya','deskripsi','kodebank'); var pageSize = 18; var ds_jbiaya = RH.JsonStore({ url : BASE_URL + 'jbiaya_controller/get_jbiaya', fields : fields_jbiaya, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jbiaya = RH.searchComp({ id : 'sb_jbiaya', fields : ['kdjnsbiaya:Kode','nmjnsbiaya:Nama','kodebank:Kode Bank'], selected : 'nmjnsbiaya', store : ds_jbiaya }); // COLUMN MODEL var cm_jbiaya = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdjnsbiaya', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmjnsbiaya', sortable: true }, { header: RH.h3('Kode Bank'), width: 100, dataIndex: 'kodebank', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jbiaya = RH.GridPanel_T1({ ds: ds_jbiaya, cm: cm_jbiaya, singleSelect: true, searchComp: sb_jbiaya, allowAdd: true, fnAdd: fnAddJbiaya, pageSize: pageSize, cellclick: onCellJbiayaClick }); var fp_jbiaya = RH.GPContainer1({ title: 'Jenis Biaya', iconCls:'silk-house', gridPanel: gp_jbiaya, }); SET_PAGE_CONTENT(fp_jbiaya); /** FUNCTIONS */ function onCellJbiayaClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJbiaya(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJbiaya(grid, record)}); } function reloadJbiaya(){ ds_jbiaya.reload(); } function fnAddJbiaya(){ var grid = gp_jbiaya; wEntryJbiaya(false, grid, null); } function fnEditJbiaya(grid, record){ wEntryJbiaya(true, grid, record); } function fnDeleteJbiaya(grid, record){ var url = BASE_URL + 'jbiaya_controller/delete_jbiaya'; var params = new Object({ idjnsbiaya : record.data['idjnsbiaya'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS BIAYA */ function wEntryJbiaya(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis Biaya (Edit)':'Jenis Biaya (Entry)'; /** DATA SOURCE GRUP JENIS BIAYA */ /*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 jbiaya_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jbiaya', 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.kdjnsbiaya', fieldLabel: 'Kode', width: 150, allowBlank: false, maxLength:4, minLength:2 },{ id: 'tf.frm.nmjnsbiaya', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ id: 'tf.frm.kodebank', fieldLabel: 'Kode Bank', width: 300, allowBlank: true, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJbiaya(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJbiaya.close(); } }] }); var wJbiaya = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jbiaya_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJbiayaForm(isUpdate, record); wJbiaya.show(); /** FORM FUNCTIONS */ function setJbiayaForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnsbiaya'); RH.setCompValue('tf.frm.kdjnsbiaya', record.data['kdjnsbiaya']); RH.setCompValue('tf.frm.nmjnsbiaya', record.data['nmjnsbiaya']); RH.setCompValue('tf.frm.kodebank', record.data['kodebank']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveJbiaya(){ var idForm = 'frm.jbiaya'; var sUrl = BASE_URL +'jbiaya_controller/insert_jbiaya'; var sParams = new Object({ kdjnsbiaya : RH.getCompValue('tf.frm.kdjnsbiaya'), nmjnsbiaya : RH.getCompValue('tf.frm.nmjnsbiaya'), kodebank : RH.getCompValue('tf.frm.kodebank'), 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 +'jbiaya_controller/update_jbiaya'; sParams.idjnsbiaya = record.data['idjnsbiaya']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJbiaya, msgWait, msgSuccess, msgFail, msgInvalid); } }