function pCutidet(){ var fields_cutidet = RH.storeFields('idcutidet','nmcutidet'); var pageSize = 18; var ds_cutidet = RH.JsonStore({ url : BASE_URL + 'cutidet_controller/get_cutidet', fields : fields_cutidet, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_cutidet = RH.searchComp({ id : 'sb_cutidet', fields : ['nmcutidet:Nama'], selected : 'nmcutidet', store : ds_cutidet }); // COLUMN MODEL var cm_cutidet = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('ID'), width: 300, dataIndex: 'idcutidet', sortable: true, hidden:true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmcutidet', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_cutidet = RH.GridPanel_T1({ ds: ds_cutidet, cm: cm_cutidet, singleSelect: true, searchComp: sb_cutidet, allowAdd: true, fnAdd: fnAddCutidet, pageSize: pageSize, cellclick: onCellCutidetClick }); var fp_cutidet = RH.GPContainer1({ title: 'Setting Cuti Detail (Non-Aktif)', iconCls:'silk-house', gridPanel: gp_cutidet, }); SET_PAGE_CONTENT(fp_cutidet); /** FUNCTIONS */ function onCellCutidetClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditCutidet(grid, record)}); RH.DeleteClick(e, function(){fnDeleteCutidet(grid, record)}); } function reloadCutidet(){ ds_cutidet.reload(); } function fnAddCutidet(){ var grid = gp_cutidet; wEntryCutidet(false, grid, null); } function fnEditCutidet(grid, record){ wEntryCutidet(true, grid, record); } function fnDeleteCutidet(grid, record){ var url = BASE_URL + 'cutidet_controller/delete_cutidet'; var params = new Object({ idcutidet : record.data['idcutidet'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT CUTI DETAIL */ function wEntryCutidet(isUpdate, grid, record){ var winTitle = (isUpdate)?'Setting Cuti Deatil (Edit)':'Setting Cuti Detail (Entry)'; /** DATA SOURCE GRUP CUTI DETAIL */ /*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 CUTI DETAIL */ var cutidet_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.cutidet', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 100, width: 475, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.idcutidet', fieldLabel: 'ID', hidden:true, width: 300, },{ id: 'tf.frm.nmcutidet', fieldLabel: 'Nama', width: 300, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveCutidet(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wCutidet.close(); } }] }); var wCutidet = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [cutidet_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setCutidetForm(isUpdate, record); wCutidet.show(); /** FORM FUNCTIONS */ function setCutidetForm(isUpdate, record){ //var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdstkuitansi'); RH.setCompValue('tf.frm.idcutidet', record.data['idcutidet']); RH.setCompValue('tf.frm.nmcutidet', record.data['nmcutidet']); //RH.setCompValue('tf.frm.nmcutidet', record.data['nmstkuitansi']); //RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveCutidet(){ var idForm = 'frm.cutidet'; var sUrl = BASE_URL +'cutidet_controller/insert_cutidet'; var sParams = new Object({ //kdstkuitansi : RH.getCompValue('tf.frm.kdstkuitansi'), nmcutidet : RH.getCompValue('tf.frm.nmcutidet'), //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 +'cutidet_controller/update_cutidet'; sParams.idcutidet = record.data['idcutidet']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wCutidet, msgWait, msgSuccess, msgFail, msgInvalid); } }