function pStambilmk(){ var fields_stambilmk = RH.storeFields('idstambilmk','kdstambilmk','nmstambilmk'); var pageSize = 18; var ds_stambilmk = RH.JsonStore({ url : BASE_URL + 'stambilmk_controller/get_stambilmk', fields : fields_stambilmk, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_stambilmk = RH.searchComp({ id : 'sb_stambilmk', fields : ['kdstambilmk:Kode','nmstambilmk:Nama'], selected : 'nmstambilmk', store : ds_stambilmk }); // COLUMN MODEL var cm_stambilmk = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdstambilmk', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmstambilmk', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_stambilmk = RH.GridPanel_T1({ ds: ds_stambilmk, cm: cm_stambilmk, singleSelect: true, searchComp: sb_stambilmk, allowAdd: true, fnAdd: fnAddStambilmk, pageSize: pageSize, cellclick: onCellStambilmkClick }); var fp_stambilmk = RH.GPContainer1({ title: 'Status Ambil Mata Kuliah', iconCls:'silk-house', gridPanel: gp_stambilmk, }); SET_PAGE_CONTENT(fp_stambilmk); /** FUNCTIONS */ function onCellStambilmkClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditStambilmk(grid, record)}); RH.DeleteClick(e, function(){fnDeleteStambilmk(grid, record)}); } function reloadStambilmk(){ ds_stambilmk.reload(); } function fnAddStambilmk(){ var grid = gp_stambilmk; wEntryStambilmk(false, grid, null); } function fnEditStambilmk(grid, record){ wEntryStambilmk(true, grid, record); } function fnDeleteStambilmk(grid, record){ var url = BASE_URL + 'stambilmk_controller/delete_stambilmk'; var params = new Object({ idstambilmk : record.data['idstambilmk'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT STATUS AMBIL MATA KULIAH */ function wEntryStambilmk(isUpdate, grid, record){ var winTitle = (isUpdate)?'Status Ambil Mata Kuliah (Edit)':'Status Ambil Mata Kuliah (Entry)'; /** DATA SOURCE GRUP STATUS AMBIL MATA KULIAH */ /*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 stambilmk_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stambilmk', 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.kdstambilmk', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmstambilmk', fieldLabel: 'Nama', width: 300, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveStambilmk(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wStambilmk.close(); } }] }); var wStambilmk = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stambilmk_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStambilmkForm(isUpdate, record); wStambilmk.show(); /** FORM FUNCTIONS */ function setStambilmkForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdstambilmk'); RH.setCompValue('tf.frm.kdstambilmk', record.data['kdstambilmk']); RH.setCompValue('tf.frm.nmstambilmk', record.data['nmstambilmk']); return; } } } function fnSaveStambilmk(){ var idForm = 'frm.stambilmk'; var sUrl = BASE_URL +'stambilmk_controller/insert_stambilmk'; var sParams = new Object({ kdstambilmk : RH.getCompValue('tf.frm.kdstambilmk'), nmstambilmk : RH.getCompValue('tf.frm.nmstambilmk'), }); 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 +'stambilmk_controller/update_stambilmk'; sParams.idstambilmk = record.data['idstambilmk']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStambilmk, msgWait, msgSuccess, msgFail, msgInvalid); } }