function pJkelas(){ var fields_jkelas = RH.storeFields('idjnskls','kdjnskls','nmjnskls','deskripsi'); /** store */ var pageSize = 18; var ds_jkelas = RH.JsonStore({ url : BASE_URL + 'jkelas_controller/get_jkelas', fields : fields_jkelas, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jkelas = RH.searchComp({ id : 'sb_jkelas', fields : ['kdjnskls:Kode','nmjnskls:Nama'], selected : 'nmjnskls', store : ds_jkelas }); var cm_jkelas = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'idjnskls', dataIndex: 'idjnskls', hidden: true }, { header: 'Kode',width: 80, dataIndex: 'kdjnskls', sortable: true }, { header: 'Nama', width: 200, dataIndex: 'nmjnskls', sortable: true }, { header: 'Deskripsi', width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jkelas = RH.GridPanel_T1({ ds: ds_jkelas, cm: cm_jkelas, singleSelect: true, searchComp: sb_jkelas, allowAdd: true, fnAdd: fnAddJkelas, pageSize: pageSize, cellclick: onCellJkelasClick }); var fp_jkelas = new Ext.Panel({ xtype: 'panel', title: 'Jenis Kelas', iconCls:'silk-house', buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, layout: 'fit', waitMsg: 'Waiting...', maskDisabled: false, monitorValid: true, frame: true, items: [{ xtype: 'panel', layout:'fit', items: [gp_jkelas], }], }); SET_PAGE_CONTENT(fp_jkelas); /** FUNCTIONS */ function onCellJkelasClick(grid, rowIndex, columnIndex, e) { var t = e.getTarget(); var record = grid.getStore().getAt(rowIndex); // Get the Record //var columnId = grid.getColumnModel().getId(columnIndex); // Get column id var sm = grid.getSelectionModel(); var sel = sm.getSelected(); if (t.className == 'imgEdit') { fnEditJkelas(grid, record); return true; } if (t.className == 'imgDelete') { fnDeleteJkelas(grid, record); return true; } return false; } function reloadJkelas(){ ds_jkelas.reload(); } function fnAddJkelas(){ var grid = gp_jkelas; wform_jkelas(false, grid, null); } function fnEditJkelas(grid, record){ wform_jkelas(true, grid, record); } function fnDeleteJkelas(grid, record){ var url = BASE_URL + 'jkelas_controller/delete_jkelas'; var params = new Object({ idjnskls : record.data['idjnskls'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS KELAS */ function wform_jkelas(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis Kelas (Edit)':'Jenis Kelas (Entry)'; /** THE FORM */ var jkelas_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jkelas', buttonAlign: 'left', labelWidth: 100, 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.kdjnskls', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmjnskls', fieldLabel: 'Jenis Kelas', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJkelas(); } }, { text: 'Kembali', iconCls:'', handler: function() { wJkelas.close(); } }] }); var wJkelas = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jkelas_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJkelasForm(isUpdate, record); wJkelas.show(); /** FORM FUNCTIONS */ function setJkelasForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //Ext.getCmp('tf.frm.kdjnskls').disable(); RH.setCompValue('tf.frm.kdjnskls', record.data['kdjnskls']); RH.setCompValue('tf.frm.nmjnskls', record.data['nmjnskls']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveJkelas(){ var idForm = 'frm.jkelas'; var sUrl = BASE_URL +'jkelas_controller/insert_jkelas'; var sParams = getInsertJkelasParams(); 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 +'jkelas_controller/update_jkelas'; sParams.idjnskls = record.data['idjnskls']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJkelas, msgWait, msgSuccess, msgFail, msgInvalid); } // GET PARAMETERS FOR INSERT/UPDATE function getInsertJkelasParams(){ return new Object({ kdjnskls : RH.getCompValue('tf.frm.kdjnskls'), nmjnskls : RH.getCompValue('tf.frm.nmjnskls'), deskripsi : RH.getCompValue('ta.frm.deskripsi'), }); } }