function pJabatan(){ var fields_Jabatan = RH.storeFields('idjabatan','kdjabatan','nmjabatan'); var pageSize = 15; var ds_Jabatan = RH.JsonStore({ url : BASE_URL + 'jabatan_controller/get_jabatan', fields : fields_Jabatan, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_Jabatan = RH.searchComp({ id : 'sb_jabatan', fields : ['kdjabatan:Kode', 'nmjabatan:Jabatan'], selected : 'kdjabatan', store : ds_Jabatan }); var cm_Jabatan = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'ID',width: 200, dataIndex: 'idjabatan', sortable: true, hidden: true }, { header: 'Kode',width: 100, dataIndex: 'kdjabatan', sortable: true }, { header: 'Jabatan',width: 250, dataIndex: 'nmjabatan', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_Jabatan = RH.GridPanel_T1({ ds: ds_Jabatan, cm: cm_Jabatan, singleSelect: true, searchComp: sb_Jabatan, allowAdd: true, fnAdd: fnAddJabatan, pageSize: pageSize, cellclick: onCellJabatanClick }); var fp_Jabatan = RH.GPContainer1({ title: 'Jabatan', iconCls:'silk-user', gridPanel: gp_Jabatan, }); SET_PAGE_CONTENT(fp_Jabatan); /** FUNCTIONS */ function onCellJabatanClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJabatan(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJabatan(grid, record)}); } function reloadJabatan(){ ds_Jabatan.reload(); } function fnAddJabatan(){ var grid = gp_Jabatan; wform_Jabatan(false, grid, null); } function fnEditJabatan(grid, record){ wform_Jabatan(true, grid, record); } function fnDeleteJabatan(grid, record){ var url = BASE_URL + 'pimpinan_controller/delete_pimpinan'; var params = new Object({ idpimpinan : record.data['idpimpinan'] }); RH.deleteGridRecord(url, params, grid ); } function wform_Jabatan(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jabatan (Edit)':'Jabatan (Entry)'; var Jabatan_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.Jabatan', buttonAlign: 'left', labelWidth: 200, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 150, width: 600, autoScroll: true, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'id_idjabatan', hidden: true, },{ id: 'id_kdjabatan', fieldLabel: 'Kode', width: 100, allowBlank: true, },{ id: 'id_nmjabatan', fieldLabel: 'Jabatan', width: 250, allowBlank: true, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJabatan(); } }, { text: 'Kembali', iconCls:'', handler: function() { wJabatan.close(); } }] }); var wJabatan = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [Jabatan_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJabatan(isUpdate, record); wJabatan.show(); /** FORM FUNCTIONS */ function setJabatan(isUpdate, record){ if(isUpdate){ if(record != null){ RH.setCompValue('id_idjabatan', record.data['idjabatan']); RH.setCompValue('id_kdjabatan', record.data['kdjabatan']); RH.setCompValue('id_nmjabatan', record.data['nmjabatan']); return; } } } function fnSaveJabatan(){ var idForm = 'frm.Jabatan'; var sUrl = BASE_URL +'jabatan_controller/insert_jabatan'; var sParams = getInsertJabatanParams(); 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 +'jabatan_controller/update_jabatan'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJabatan, msgWait, msgSuccess, msgFail, msgInvalid); } function getInsertJabatanParams(){ return new Object({ idjabatan : RH.getCompValue('id_idjabatan'), kdjabatan : RH.getCompValue('id_kdjabatan'), nmjabatan : RH.getCompValue('id_nmjabatan'), }); } } }