function pJdiskon(){ var fields_jdiskon = RH.storeFields('idjnsdiskon','kdjnsdiskon','nmdiskon','deskripsi','nominal'); var pageSize = 18; var ds_jdiskon = RH.JsonStore({ url : BASE_URL + 'jdiskon_controller/get_jdiskon', fields : fields_jdiskon, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jdiskon = RH.searchComp({ id : 'sb_jdiskon', fields : ['kdjnsdiskon:Kode','nmdiskon:Nama'], selected : 'nmdiskon', store : ds_jdiskon }); // COLUMN MODEL var cm_jdiskon = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdjnsdiskon', sortable: true }, { header: RH.h3('Nama'), width: 200, dataIndex: 'nmdiskon', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, { header: RH.h3('Nominal'), width: 200, dataIndex: 'nominal', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jdiskon = RH.GridPanel_T1({ ds: ds_jdiskon, cm: cm_jdiskon, singleSelect: true, searchComp: sb_jdiskon, allowAdd: true, fnAdd: fnAddJdiskon, pageSize: pageSize, cellclick: onCellJdiskonClick }); var fp_jdiskon = RH.GPContainer1({ title: 'Jenis Diskon', iconCls:'silk-house', gridPanel: gp_jdiskon, }); SET_PAGE_CONTENT(fp_jdiskon); /** FUNCTIONS */ function onCellJdiskonClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJdiskon(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJdiskon(grid, record)}); } function reloadJdiskon(){ ds_jdiskon.reload(); } function fnAddJdiskon(){ var grid = gp_jdiskon; wEntryJdiskon(false, grid, null); } function fnEditJdiskon(grid, record){ wEntryJdiskon(true, grid, record); } function fnDeleteJdiskon(grid, record){ var url = BASE_URL + 'jdiskon_controller/delete_jdiskon'; var params = new Object({ idjnsdiskon : record.data['idjnsdiskon'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS DISKON */ function wEntryJdiskon(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis Diskon (Edit)':'Jenis Diskon (Entry)'; /** DATA SOURCE GRUP JENIS DISKON */ /*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 jdiskon_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jdiskon', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 250, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.kdjnsdiskon', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmdiskon', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, },{ id: 'tf.frm.nominal', fieldLabel: 'Nominal', width: 200, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJdiskon(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJdiskon.close(); } }] }); var wJdiskon = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jdiskon_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJdiskonForm(isUpdate, record); wJdiskon.show(); /** FORM FUNCTIONS */ function setJdiskonForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnsdiskon'); RH.setCompValue('tf.frm.kdjnsdiskon', record.data['kdjnsdiskon']); RH.setCompValue('tf.frm.nmdiskon', record.data['nmdiskon']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); RH.setCompValue('tf.frm.nominal', record.data['nominal']); return; } } } function fnSaveJdiskon(){ var idForm = 'frm.jdiskon'; var sUrl = BASE_URL +'jdiskon_controller/insert_jdiskon'; var sParams = new Object({ kdjnsdiskon : RH.getCompValue('tf.frm.kdjnsdiskon'), nmdiskon : RH.getCompValue('tf.frm.nmdiskon'), deskripsi : RH.getCompValue('ta.frm.deskripsi'), nominal : RH.getCompValue('tf.frm.nominal'), }); 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 +'jdiskon_controller/update_jdiskon'; sParams.idjnsdiskon = record.data['idjnsdiskon']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJdiskon, msgWait, msgSuccess, msgFail, msgInvalid); } }