function pKlsmhs(){ var ds_jkls = store_jkls(); var ds_status = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_status ', method: 'POST' }), root: 'data', autoLoad: true, fields: [{ name: "idstatus" }, { name: "nmstatus" }] }); var wAddEditStoresObj = new Object({ jkls: ds_jkls, status:ds_status}); var fields_klsmhs = RH.storeFields('idklsmhs','kdklsmhs','nmklsmhs','deskripsi','idjnskls','nmjnskls','idstatus','nmstatus'); var pageSize = 18; var ds_klsmhs = RH.JsonStore({ url : BASE_URL + 'klsmhs_controller/get_klsmhs', fields : fields_klsmhs, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_klsmhs = RH.searchComp({ id : 'sb_klsmhs', fields : ['kdklsmhs:Kode','nmklsmhs:Nama'], selected : 'nmklsmhs', store : ds_klsmhs }); // COLUMN MODEL var cm_klsmhs = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Kode',width: 100, dataIndex: 'kdklsmhs', sortable: true }, { header: 'Nama', width: 200, dataIndex: 'nmklsmhs', sortable: true }, { header: 'Deskripsi', width: 300, dataIndex: 'deskripsi', sortable: true }, { header: 'Jenis Kelas', width: 200, dataIndex: 'nmjnskls', sortable: true }, { header: 'Status', width: 100, dataIndex: 'nmstatus', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_klsmhs = RH.GridPanel_T1({ ds: ds_klsmhs, cm: cm_klsmhs, singleSelect: true, searchComp: sb_klsmhs, allowAdd: true, fnAdd: fnAddKlsmhs, pageSize: pageSize, cellclick: onCellKlsmhsClick }); var fp_klsmhs = RH.GPContainer1({ title: 'Kelas Mahasiswa', iconCls:'silk-house', gridPanel: gp_klsmhs, }); SET_PAGE_CONTENT(fp_klsmhs); /** FUNCTIONS */ function onCellKlsmhsClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditKlsmhs(grid, record)}); RH.DeleteClick(e, function(){fnDeleteKlsmhs(grid, record)}); } function reloadKlsmhs(){ ds_klsmhs.reload(); } function fnAddKlsmhs(){ var grid = gp_klsmhs; wEntryKlsmhs(false, grid, null, wAddEditStoresObj); } function fnEditKlsmhs(grid, record){ wEntryKlsmhs(true, grid, record, wAddEditStoresObj); } function fnDeleteKlsmhs(grid, record){ var url = BASE_URL + 'klsmhs_controller/delete_klsmhs'; var params = new Object({ idklsmhs : record.data['idklsmhs'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT KELAS MAHASISWA */ function wEntryKlsmhs(isUpdate, grid, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Kelas Mahasiswa (Edit)':'Kelas Mahasiswa (Entry)'; /** DATA SOURCE GRUP KELAS MAHASISWA */ var ds_jkls = wAddEditStoresObj.jkls; var ds_status = wAddEditStoresObj.status; /** FORM ENTRY/EDIT MATA-KULIAH */ var klsmhs_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.klsmhs', 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.kdklsmhs', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmklsmhs', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, },{ xtype: 'combo', id: 'cb.frm.idjnskls', fieldLabel: 'Jenis Kelas', allowBlank: false, editable:false, store: ds_jkls, triggerAction: 'all', valueField: 'idjnskls', displayField: 'nmjnskls', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, },{ xtype: 'combo', id: 'cb.frm.idstatus', fieldLabel: 'Status', store: ds_status, triggerAction: 'all', valueField: 'idstatus', displayField: 'nmstatus', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 150, allowBlank: false, editable:false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveKlsmhs(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wKlsmhs.close(); } }] }); var wKlsmhs = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [klsmhs_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setKlsmhsForm(isUpdate, record); wKlsmhs.show(); /** FORM FUNCTIONS */ function setKlsmhsForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdklsmhs'); RH.setCompValue('tf.frm.kdklsmhs', record.data['kdklsmhs']); RH.setCompValue('tf.frm.nmklsmhs', record.data['nmklsmhs']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); RH.setCompValue('cb.frm.idjnskls', record.data['idjnskls']); RH.setCompValue('cb.frm.idstatus', record.data['idstatus']); return; } } } function fnSaveKlsmhs(){ var idForm = 'frm.klsmhs'; var sUrl = BASE_URL +'klsmhs_controller/insert_klsmhs'; var sParams = new Object({ kdklsmhs : RH.getCompValue('tf.frm.kdklsmhs'), nmklsmhs : RH.getCompValue('tf.frm.nmklsmhs'), deskripsi : RH.getCompValue('ta.frm.deskripsi'), idjnskls : RH.getCompValue('cb.frm.idjnskls'), idstatus : RH.getCompValue('cb.frm.idstatus'), }); 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 +'klsmhs_controller/update_klsmhs'; sParams.idklsmhs = record.data['idklsmhs']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wKlsmhs, msgWait, msgSuccess, msgFail, msgInvalid); } }