function pJujian(){ var fields_jujian = RH.storeFields('idjnsujian','kdjnsujian','nmjnsujian','deskripsi'); var pageSize = 18; var ds_jujian = RH.JsonStore({ url : BASE_URL + 'jujian_controller/get_jujian', fields : fields_jujian, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jujian = RH.searchComp({ id : 'sb_jujian', fields : ['kdjnsujian:Kode','nmjnsujian:Nama'], selected : 'nmjnsujian', store : ds_jujian }); // COLUMN MODEL var cm_jujian = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdjnsujian', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmjnsujian', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jujian = RH.GridPanel_T1({ ds: ds_jujian, cm: cm_jujian, singleSelect: true, searchComp: sb_jujian, allowAdd: true, fnAdd: fnAddJujian, pageSize: pageSize, cellclick: onCellJujianClick }); var fp_jujian = RH.GPContainer1({ title: 'Jenis Ujian', iconCls:'silk-house', gridPanel: gp_jujian, }); SET_PAGE_CONTENT(fp_jujian); /** FUNCTIONS */ function onCellJujianClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJujian(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJujian(grid, record)}); } function reloadJujian(){ ds_jujian.reload(); } function fnAddJujian(){ var grid = gp_jujian; wEntryJujian(false, grid, null); } function fnEditJujian(grid, record){ wEntryJujian(true, grid, record); } function fnDeleteJujian(grid, record){ var url = BASE_URL + 'jujian_controller/delete_jujian'; var params = new Object({ idjnsujian : record.data['idjnsujian'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS UJIAN */ function wEntryJujian(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis Ujian (Edit)':'Jenis Ujian (Entry)'; /** DATA SOURCE GRUP JENIS UJIAN */ /*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 jujian_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jujian', 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.kdjnsujian', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmjnsujian', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJujian(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJujian.close(); } }] }); var wJujian = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jujian_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJujianForm(isUpdate, record); wJujian.show(); /** FORM FUNCTIONS */ function setJujianForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnsujian'); RH.setCompValue('tf.frm.kdjnsujian', record.data['kdjnsujian']); RH.setCompValue('tf.frm.nmjnsujian', record.data['nmjnsujian']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveJujian(){ var idForm = 'frm.jujian'; var sUrl = BASE_URL +'jujian_controller/insert_jujian'; var sParams = new Object({ kdjnsujian : RH.getCompValue('tf.frm.kdjnsujian'), nmjnsujian : RH.getCompValue('tf.frm.nmjnsujian'), 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 +'jujian_controller/update_jujian'; sParams.idjnsujian = record.data['idjnsujian']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJujian, msgWait, msgSuccess, msgFail, msgInvalid); } }