function pJskripsi(){ var fields_jskripsi = RH.storeFields('kdjskripsi','nmjskripsi','',''); var pageSize = 18; var ds_jskripsi = RH.JsonStore({ url : BASE_URL + 'jnsskripsi_controller/get_jskripsi', fields : fields_jskripsi, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jskripsi = RH.searchComp({ id : 'sb_jskripsi', fields : ['kdjskripsi:Kode','nmjskripsi:Nama'], selected : 'nmjskripsi', store : ds_jskripsi }); // COLUMN MODEL var cm_jskripsi = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdjskripsi', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmjskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jskripsi = RH.GridPanel_T1({ ds: ds_jskripsi, cm: cm_jskripsi, singleSelect: true, searchComp: sb_jskripsi, allowAdd: true, fnAdd: fnAddJskripsi, pageSize: pageSize, cellclick: onCellJskripsiClick }); var fp_jskripsi = RH.GPContainer1({ title: 'Jenis Skripsi', iconCls:'silk-house', gridPanel: gp_jskripsi, }); SET_PAGE_CONTENT(fp_jskripsi); /** FUNCTIONS */ function onCellJskripsiClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJskripsi(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJskripsi(grid, record)}); } function reloadJskripsi(){ ds_jskripsi.reload(); } function fnAddJskripsi(){ var grid = gp_jskripsi; wEntryJskripsi(false, grid, null); } function fnEditJskripsi(grid, record){ wEntryJskripsi(true, grid, record); } function fnDeleteJskripsi(grid, record){ var url = BASE_URL + 'jnsskripsi_controller/delete_jskripsi'; var params = new Object({ kdjskripsi : record.data['kdjskripsi'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS SKRIPSI */ function wEntryJskripsi(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis Skripsi (Edit)':'Jenis Skripsi (Entry)'; /** DATA SOURCE GRUP JENIS SKRIPSI */ /*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 jskripsi_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jskripsi', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 150, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.kdjskripsi', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmjskripsi', fieldLabel: 'Nama', width: 300, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJskripsi(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJskripsi.close(); } }] }); var wJskripsi = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jskripsi_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJskripsiForm(isUpdate, record); wJskripsi.show(); /** FORM FUNCTIONS */ function setJskripsiForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ RH.disableComp('tf.frm.kdjskripsi'); RH.setCompValue('tf.frm.kdjskripsi', record.data['kdjskripsi']); RH.setCompValue('tf.frm.nmjskripsi', record.data['nmjskripsi']); return; } } } function fnSaveJskripsi(){ var idForm = 'frm.jskripsi'; var sUrl = BASE_URL +'jnsskripsi_controller/insert_jskripsi'; var sParams = new Object({ kdjskripsi : RH.getCompValue('tf.frm.kdjskripsi'), nmjskripsi : RH.getCompValue('tf.frm.nmjskripsi'), }); 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 +'jnsskripsi_controller/update_jskripsi'; sParams.kdjnskls = record.data['kdjnskls']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJskripsi, msgWait, msgSuccess, msgFail, msgInvalid); } }