function pStkuitansi(){ var fields_stkuitansi = RH.storeFields('idstkuitansi','kdstkuitansi','nmstkuitansi','deskripsi'); var pageSize = 18; var ds_stkuitansi = RH.JsonStore({ url : BASE_URL + 'stkuitansi_controller/get_stkuitansi', fields : fields_stkuitansi, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_stkuitansi = RH.searchComp({ id : 'sb_stkuitansi', fields : ['kdstkuitansi:Kode','nmstkuitansi:Nama'], selected : 'nmstkuitansi', store : ds_stkuitansi }); // COLUMN MODEL var cm_stkuitansi = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdstkuitansi', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmstkuitansi', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_stkuitansi = RH.GridPanel_T1({ ds: ds_stkuitansi, cm: cm_stkuitansi, singleSelect: true, searchComp: sb_stkuitansi, allowAdd: true, fnAdd: fnAddStkuitansi, pageSize: pageSize, cellclick: onCellStkuitansiClick }); var fp_stkuitansi = RH.GPContainer1({ title: 'Status Kuitansi', iconCls:'silk-house', gridPanel: gp_stkuitansi, }); SET_PAGE_CONTENT(fp_stkuitansi); /** FUNCTIONS */ function onCellStkuitansiClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditStkuitansi(grid, record)}); RH.DeleteClick(e, function(){fnDeleteStkuitansi(grid, record)}); } function reloadStkuitansi(){ ds_stkuitansi.reload(); } function fnAddStkuitansi(){ var grid = gp_stkuitansi; wEntryStkuitansi(false, grid, null); } function fnEditStkuitansi(grid, record){ wEntryStkuitansi(true, grid, record); } function fnDeleteStkuitansi(grid, record){ var url = BASE_URL + 'stkuitansi_controller/delete_stkuitansi'; var params = new Object({ idstkuitansi : record.data['idstkuitansi'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT STATUS KUITANSI */ function wEntryStkuitansi(isUpdate, grid, record){ var winTitle = (isUpdate)?'Status Kuitansi (Edit)':'Status Kuitansi (Entry)'; /** DATA SOURCE GRUP STATUS KUITANSI */ /*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 stkuitansi_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stkuitansi', 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.kdstkuitansi', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmstkuitansi', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveStkuitansi(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wStkuitansi.close(); } }] }); var wStkuitansi = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stkuitansi_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStkuitansiForm(isUpdate, record); wStkuitansi.show(); /** FORM FUNCTIONS */ function setStkuitansiForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdstkuitansi'); RH.setCompValue('tf.frm.kdstkuitansi', record.data['kdstkuitansi']); RH.setCompValue('tf.frm.nmstkuitansi', record.data['nmstkuitansi']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveStkuitansi(){ var idForm = 'frm.stkuitansi'; var sUrl = BASE_URL +'stkuitansi_controller/insert_stkuitansi'; var sParams = new Object({ kdstkuitansi : RH.getCompValue('tf.frm.kdstkuitansi'), nmstkuitansi : RH.getCompValue('tf.frm.nmstkuitansi'), 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 +'stkuitansi_controller/update_stkuitansi'; sParams.idstkuitansi = record.data['idstkuitansi']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStkuitansi, msgWait, msgSuccess, msgFail, msgInvalid); } }