function pBebanStudi(){ var fields_bebanstudi = RH.storeFields('idbebanstudi','ipmin','ipmax','sksmin','sksmax'); var pageSize = 18; var ds_bebanstudi = RH.JsonStore({ url : BASE_URL + 'bebanstudi_controller/get_bebanstudi', fields : fields_bebanstudi, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_bebanstudi = RH.searchComp({ id : 'sb_bebanstudi', fields : ['ipmin:IPK Minimal','ipmax:IPK Maksimal','sksmin:SKS Minimal','sksmax:SKS Maksimal'], selected : 'ipmin', store : ds_bebanstudi }); // COLUMN MODEL var cm_bebanstudi = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('IPK Minimal'),width: 100, dataIndex: 'ipmin', sortable: true, align:'right' }, { header: RH.h3('IPK Maksimal'), width: 100, dataIndex: 'ipmax', sortable: true, align:'right' }, { header: RH.h3('SKS Minimal'), width: 100, dataIndex: 'sksmin', sortable: true, align:'right' }, { header: RH.h3('SKS Maksimal'), width: 100, dataIndex: 'sksmax', sortable: true, align:'right' }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_bebanstudi = RH.GridPanel_T1({ ds: ds_bebanstudi, cm: cm_bebanstudi, singleSelect: true, searchComp: sb_bebanstudi, allowAdd: true, fnAdd: fnAddBebanstudi, pageSize: pageSize, cellclick: onCellBebanstudiClick }); var fp_bebanstudi = RH.GPContainer1({ title: 'Beban Studi', iconCls:'silk-house', gridPanel: gp_bebanstudi, }); SET_PAGE_CONTENT(fp_bebanstudi); /** FUNCTIONS */ function onCellBebanstudiClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditBebanstudi(grid, record)}); RH.DeleteClick(e, function(){fnDeleteBebanstudi(grid, record)}); } function reloadBebanstudi(){ ds_bebanstudi.reload(); } function fnAddBebanstudi(){ var grid = gp_bebanstudi; wEntryBebanstudi(false, grid, null); } function fnEditBebanstudi(grid, record){ wEntryBebanstudi(true, grid, record); } function fnDeleteBebanstudi(grid, record){ var url = BASE_URL + 'bebanstudi_controller/delete_bebanstudi'; var params = new Object({ idbebanstudi : record.data['idbebanstudi'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT SET IPK */ function wEntryBebanstudi(isUpdate, grid, record){ var winTitle = (isUpdate)?'Beban Studi (Edit)':'Beban Studi (Entry)'; /** FORM ENTRY/EDIT MATA-KULIAH */ var bebanstudi_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.bebanstudi', 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.idbebanstudi', xtype: 'hidden', },{ id: 'tf.frm.ipmin', maskRe: /[0-9.]/, fieldLabel: 'IPK Minimal', width: 150, allowBlank: false, },{ id: 'tf.frm.ipmax', maskRe: /[0-9.]/, fieldLabel: 'IPK Maksimal', width: 150, allowBlank: false, },{ id: 'tf.frm.sksmin', maskRe: /[0-9.]/, fieldLabel: 'SKS Minimal', width: 150, allowBlank: false, },{ id: 'tf.frm.sksmax', maskRe: /[0-9.]/, fieldLabel: 'SKS Maksimal', width: 150, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveBebanstudi(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wBebanstudi.close(); } }] }); var wBebanstudi = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [bebanstudi_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setBebanstudiForm(isUpdate, record); wBebanstudi.show(); /** FORM FUNCTIONS */ function setBebanstudiForm(isUpdate, record){ if(isUpdate){ if(record != null){ RH.setCompValue('tf.frm.idbebanstudi', record.data['idbebanstudi']); RH.setCompValue('tf.frm.ipmin', record.data['ipmin']); RH.setCompValue('tf.frm.ipmax', record.data['ipmax']); RH.setCompValue('tf.frm.sksmin', record.data['sksmin']); RH.setCompValue('tf.frm.sksmax', record.data['sksmax']); return; } } } function fnSaveBebanstudi(){ var idForm = 'frm.bebanstudi'; var sUrl = BASE_URL +'bebanstudi_controller/insert_bebanstudi'; var sParams = new Object({ idbebanstudi : RH.getCompValue('tf.frm.idbebanstudi'), ipmin : RH.getCompValue('tf.frm.ipmin'), ipmax : RH.getCompValue('tf.frm.ipmax'), sksmin : RH.getCompValue('tf.frm.sksmin'), sksmax : RH.getCompValue('tf.frm.sksmax'), }); 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 +'bebanstudi_controller/update_bebanstudi'; sParams.idsetipk = record.data['idsetipk']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wBebanstudi, msgWait, msgSuccess, msgFail, msgInvalid); } }