function pStkrs(){ var fields_stkrs = RH.storeFields('idstkrs','kdstkrs','nmstkrs',''); var pageSize = 18; var ds_stkrs = RH.JsonStore({ url : BASE_URL + 'stkrs_controller/get_stkrs', fields : fields_stkrs, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_stkrs = RH.searchComp({ id : 'sb_stkrs', fields : ['kdstkrs:Kode','nmstkrs:Nama'], selected : 'nmstkrs', store : ds_stkrs }); // COLUMN MODEL var cm_stkrs = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdstkrs', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmstkrs', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_stkrs = RH.GridPanel_T1({ ds: ds_stkrs, cm: cm_stkrs, singleSelect: true, searchComp: sb_stkrs, allowAdd: true, fnAdd: fnAddStkrs, pageSize: pageSize, cellclick: onCellStkrsClick }); var fp_stkrs = RH.GPContainer1({ title: 'Status KRS', iconCls:'silk-house', gridPanel: gp_stkrs, }); SET_PAGE_CONTENT(fp_stkrs); /** FUNCTIONS */ function onCellStkrsClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditStkrs(grid, record)}); RH.DeleteClick(e, function(){fnDeleteStkrs(grid, record)}); } function reloadStkrs(){ ds_stkrs.reload(); } function fnAddStkrs(){ var grid = gp_stkrs; wEntryStkrs(false, grid, null); } function fnEditStkrs(grid, record){ wEntryStkrs(true, grid, record); } function fnDeleteStkrs(grid, record){ var url = BASE_URL + 'stkrs_controller/delete_stkrs'; var params = new Object({ idstkrs : record.data['idstkrs'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT STATUS KRS */ function wEntryStkrs(isUpdate, grid, record){ var winTitle = (isUpdate)?'Status KRS (Edit)':'Status KRS (Entry)'; /** DATA SOURCE GRUP STATUS KRS */ /*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 stkrs_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stkrs', 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.kdstkrs', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmstkrs', fieldLabel: 'Nama', width: 300, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveStkrs(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wStkrs.close(); } }] }); var wStkrs = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stkrs_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStkrsForm(isUpdate, record); wStkrs.show(); /** FORM FUNCTIONS */ function setStkrsForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdstkrs'); RH.setCompValue('tf.frm.kdstkrs', record.data['kdstkrs']); RH.setCompValue('tf.frm.nmstkrs', record.data['nmstkrs']); return; } } } function fnSaveStkrs(){ var idForm = 'frm.stkrs'; var sUrl = BASE_URL +'stkrs_controller/insert_stkrs'; var sParams = new Object({ kdstkrs : RH.getCompValue('tf.frm.kdstkrs'), nmstkrs : RH.getCompValue('tf.frm.nmstkrs'), }); 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 +'stkrs_controller/update_stkrs'; sParams.idstkrs = record.data['idstkrs']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStkrs, msgWait, msgSuccess, msgFail, msgInvalid); } }