function pCarabyr(){ var fields_carabyr = RH.storeFields('idcarabyr','kdcarabyr','nmcarabyr','deskripsi'); var pageSize = 18; var ds_carabyr = RH.JsonStore({ url : BASE_URL + 'carabyr_controller/get_carabyr', fields : fields_carabyr, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_carabyr = RH.searchComp({ id : 'sb_carabyr', fields : ['kdcarabyr:Kode','nmcarabyr:Nama'], selected : 'nmcarabyr', store : ds_carabyr }); // COLUMN MODEL var cm_carabyr = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdcarabyr', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmcarabyr', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_carabyr = RH.GridPanel_T1({ ds: ds_carabyr, cm: cm_carabyr, singleSelect: true, searchComp: sb_carabyr, allowAdd: true, fnAdd: fnAddCarabyr, pageSize: pageSize, cellclick: onCellCarabyrClick }); var fp_carabyr = RH.GPContainer1({ title: 'Cara Bayar', iconCls:'silk-house', gridPanel: gp_carabyr, }); SET_PAGE_CONTENT(fp_carabyr); /** FUNCTIONS */ function onCellCarabyrClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditCarabyr(grid, record)}); RH.DeleteClick(e, function(){fnDeleteCarabyr(grid, record)}); } function reloadCarabyr(){ ds_carabyr.reload(); } function fnAddCarabyr(){ var grid = gp_carabyr; wEntryCarabyr(false, grid, null); } function fnEditCarabyr(grid, record){ wEntryCarabyr(true, grid, record); } function fnDeleteCarabyr(grid, record){ var url = BASE_URL + 'carabyr_controller/delete_carabyr'; var params = new Object({ idcarabyr : record.data['idcarabyr'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT CARA BAYAR */ function wEntryCarabyr(isUpdate, grid, record){ var winTitle = (isUpdate)?'Cara Bayar (Edit)':'Cara Bayar (Entry)'; /** DATA SOURCE GRUP CARA BAYAR */ /*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 carabyr_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.carabyr', 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.kdcarabyr', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmcarabyr', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveCarabyr(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wCarabyr.close(); } }] }); var wCarabyr = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [carabyr_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setCarabyrForm(isUpdate, record); wCarabyr.show(); /** FORM FUNCTIONS */ function setCarabyrForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdcarabyr'); RH.setCompValue('tf.frm.kdcarabyr', record.data['kdcarabyr']); RH.setCompValue('tf.frm.nmcarabyr', record.data['nmcarabyr']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveCarabyr(){ var idForm = 'frm.carabyr'; var sUrl = BASE_URL +'carabyr_controller/insert_carabyr'; var sParams = new Object({ kdcarabyr : RH.getCompValue('tf.frm.kdcarabyr'), nmcarabyr : RH.getCompValue('tf.frm.nmcarabyr'), 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 +'carabyr_controller/update_carabyr'; sParams.idcarabyr = record.data['idcarabyr']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wCarabyr, msgWait, msgSuccess, msgFail, msgInvalid); } }