function pJslta(){ var fields_jslta = RH.storeFields('idjnsslta','kdjnsslta','nmjnsslta','deskripsi'); var pageSize = 18; var ds_jslta = RH.JsonStore({ url : BASE_URL + 'jnsslta_controller/get_jslta', fields : fields_jslta, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jslta = RH.searchComp({ id : 'sb_jslta', fields : ['kdjnsslta:Kode','nmjnsslta:Nama'], selected : 'nmjnsslta', store : ds_jslta }); // COLUMN MODEL var cm_jslta = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdjnsslta', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmjnsslta', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jslta = RH.GridPanel_T1({ ds: ds_jslta, cm: cm_jslta, singleSelect: true, searchComp: sb_jslta, allowAdd: true, fnAdd: fnAddJslta, pageSize: pageSize, cellclick: onCellJsltaClick }); var fp_jslta = RH.GPContainer1({ title: 'Jenis SLTA', iconCls:'silk-house', gridPanel: gp_jslta, }); SET_PAGE_CONTENT(fp_jslta); /** FUNCTIONS */ function onCellJsltaClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJslta(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJslta(grid, record)}); } function reloadJslta(){ ds_jslta.reload(); } function fnAddJslta(){ var grid = gp_jslta; wEntryJslta(false, grid, null); } function fnEditJslta(grid, record){ wEntryJslta(true, grid, record); } function fnDeleteJslta(grid, record){ var url = BASE_URL + 'jnsslta_controller/delete_jslta'; var params = new Object({ idjnsslta : record.data['idjnsslta'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS SLTA */ function wEntryJslta(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis SLTA (Edit)':'Jenis SLTA (Entry)'; /** DATA SOURCE GRUP JENIS SLTA */ /*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 jslta_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jslta', 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.kdjnsslta', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmjnsslta', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJslta(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJslta.close(); } }] }); var wJslta = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jslta_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJsltaForm(isUpdate, record); wJslta.show(); /** FORM FUNCTIONS */ function setJsltaForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnsslta'); RH.setCompValue('tf.frm.kdjnsslta', record.data['kdjnsslta']); RH.setCompValue('tf.frm.nmjnsslta', record.data['nmjnsslta']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveJslta(){ var idForm = 'frm.jslta'; var sUrl = BASE_URL +'jnsslta_controller/insert_jslta'; var sParams = new Object({ kdjnsslta : RH.getCompValue('tf.frm.kdjnsslta'), nmjnsslta : RH.getCompValue('tf.frm.nmjnsslta'), 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 +'jnsslta_controller/update_jslta'; sParams.idjnsslta = record.data['idjnsslta']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJslta, msgWait, msgSuccess, msgFail, msgInvalid); } }