function pKlsperkul(){ var ds_prodi = store_prodireg(); var ds_klsmhs = store_klsmhs(); var ds_status = store_status(); var ds_klsparalel = store_klsparalel(); var wAddEditStoresObj = new Object({ prodi: ds_prodi, status: ds_status, klsmhs:ds_klsmhs, paralel:ds_klsparalel}); var fields_klsperkul = RH.storeFields('idkelas','kdprodi','idklsmhs','kdkelas','nmkelas','deskripsi','idstatus','nmprodi','nmklsmhs','nmstatus','klsparalel'); var pageSize = 18; var ds_klsperkul = RH.JsonStore({ url : BASE_URL + 'klsperkul_controller/get_klsperkul', fields : fields_klsperkul, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_klsperkul = RH.searchComp({ id : 'sb_klsperkul', fields : ['nmprodi:Program Studi','nmklsmhs:Kelas Mahasiswa','nmstatus:Status'], selected : 'idstatus', store : ds_klsperkul }); // COLUMN MODEL var cm_klsperkul = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Program Studi',width: 150, dataIndex: 'nmprodi', sortable: true },{ header: 'Kelas Mahasiswa', width: 150, dataIndex: 'nmklsmhs', sortable: true },{ header: 'Nama Kelas', width: 150, dataIndex: 'nmkelas', sortable: true },{ header: 'Deskripsi', width: 300, dataIndex: 'deskripsi', sortable: true },{ header: 'Kelas Paralel', width: 150, dataIndex: 'klsparalel', sortable: true },{ header: 'Status', width: 150, dataIndex: 'nmstatus', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_klsperkul = RH.GridPanel_T1({ ds: ds_klsperkul, cm: cm_klsperkul, singleSelect: true, searchComp: sb_klsperkul, allowAdd: true, fnAdd: fnAddKlsperkul, pageSize: pageSize, cellclick: onCellKlsperkulClick }); var fp_klsperkul = RH.GPContainer1({ title: 'Kelas Perkuliahan', iconCls:'silk-house', gridPanel: gp_klsperkul, }); SET_PAGE_CONTENT(fp_klsperkul); /** FUNCTIONS */ function onCellKlsperkulClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditKlsperkul(grid, record)}); RH.DeleteClick(e, function(){fnDeleteKlsperkul(grid, record)}); } function reloadKlsperkul(){ ds_klsperkul.reload(); } function fnAddKlsperkul(){ var grid = gp_klsperkul; wEntryKlsperkul(false, grid, null, wAddEditStoresObj); } function fnEditKlsperkul(grid, record){ wEntryKlsperkul(true, grid, record, wAddEditStoresObj); } function fnDeleteKlsperkul(grid, record){ var url = BASE_URL + 'klsperkul_controller/delete_klsperkul'; var params = new Object({ idkelas : record.data['idkelas'], //kdprodi : record.data['kdprodi'], //idklsmhs : record.data['idklsmhs'], }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT KELAS PROGRAM STUDI */ function wEntryKlsperkul(isUpdate, grid, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Kelas Perkuliahan (Edit)':'Kelas Perkuliahan (Entry)'; /** DATA SOURCE GRUP KELAS PROGRAM STUDI */ var ds_prodi = wAddEditStoresObj.prodi; var ds_klsmhs = wAddEditStoresObj.klsmhs; var ds_status = wAddEditStoresObj.status; var ds_klsparalel = wAddEditStoresObj.paralel; /** FORM ENTRY/EDIT MATA-KULIAH */ var klsperkul_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.klsperkul', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 300, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { xtype: 'textfield', id: 'idkelas', fieldLabel: 'ID Kelas', hidden: true, }, { xtype: 'combo', id: 'cb.frm.kdprodi', fieldLabel: 'Program Studi', allowBlank: false, editable:false, store: ds_prodi, triggerAction: 'all', valueField: 'kdprodi', displayField: 'lnmprodi', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, },{ xtype: 'combo', id: 'cb.frm.idklsmhs', fieldLabel: 'Kelas Mahasiswa', store: ds_klsmhs, triggerAction: 'all', valueField: 'idklsmhs', displayField: 'nmklsmhs', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', //width: 200, },{ xtype: 'textfield', id: 'idkdkelas', fieldLabel: 'Kode Kelas', width: 100, allowBlank: false, },{ xtype: 'textfield', id: 'idnmkelas', fieldLabel: 'Nama Kelas', width: 150, allowBlank: false, },{ xtype: 'textarea', fieldLabel: 'Deskripsi', id: 'iddeskripsi', width: 300 },{ xtype: 'combo', id: 'cb.frm.klsparalel', fieldLabel: 'Kelas Paralel', store: ds_klsparalel, triggerAction: 'all', valueField: 'klsparalel', displayField: 'klsparalel', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', },{ 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: 200, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveKlsperkul(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wKlsperkul.close(); } }] }); var wKlsperkul = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [klsperkul_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setKlsperkulForm(isUpdate, record); wKlsperkul.show(); /** FORM FUNCTIONS */ function setKlsperkulForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ RH.disableComp('cb.frm.kdprodi'); RH.disableComp('cb.frm.idklsmhs'); RH.setCompValue('idkelas', record.data['idkelas']); RH.setCompValue('cb.frm.kdprodi', record.data['kdprodi']); RH.setCompValue('cb.frm.idklsmhs', record.data['idklsmhs']); RH.setCompValue('cb.frm.idstatus', record.data['idstatus']); RH.setCompValue('idkdkelas', record.data['kdkelas']); RH.setCompValue('idnmkelas', record.data['nmkelas']); RH.setCompValue('iddeskripsi', record.data['deskripsi']); RH.setCompValue('cb.frm.klsparalel', record.data['klsparalel']); return; } } } function fnSaveKlsperkul(){ var idForm = 'frm.klsperkul'; var sUrl = BASE_URL +'klsperkul_controller/insert_klsperkul'; var sParams = new Object({ kdprodi : RH.getCompValue('cb.frm.kdprodi'), idklsmhs : RH.getCompValue('cb.frm.idklsmhs'), idstatus : RH.getCompValue('cb.frm.idstatus'), kdkelas : RH.getCompValue('idkdkelas'), nmkelas : RH.getCompValue('idnmkelas'), deskripsi : RH.getCompValue('iddeskripsi'), idkelas : RH.getCompValue('idkelas'), klsparalel : RH.getCompValue('cb.frm.klsparalel'), }); 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 +'klsperkul_controller/update_klsperkul'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wKlsperkul, msgWait, msgSuccess, msgFail, msgInvalid); } }