function pStabsensidos(){ var fields_stabsensidos = RH.storeFields('idstabsensdos','kdstabsensidos','nmstabsensidos','deskripsi'); var pageSize = 18; var ds_stabsensidos = RH.JsonStore({ url : BASE_URL + 'stabsensidos_controller/get_stabsensidos', fields : fields_stabsensidos, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_stabsensidos = RH.searchComp({ id : 'sb_stabsensidos', fields : ['kdstabsensidos:Kode','nmstabsensidos:Nama'], selected : 'nmstabsensidos', store : ds_stabsensidos }); // COLUMN MODEL var cm_stabsensidos = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdstabsensidos', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmstabsensidos', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_stabsensidos = RH.GridPanel_T1({ ds: ds_stabsensidos, cm: cm_stabsensidos, singleSelect: true, searchComp: sb_stabsensidos, allowAdd: true, fnAdd: fnAddStabsensidos, pageSize: pageSize, cellclick: onCellStabsensidosClick }); var fp_stabsensidos = RH.GPContainer1({ title: 'Status Absensi Dosen', iconCls:'silk-house', gridPanel: gp_stabsensidos, }); SET_PAGE_CONTENT(fp_stabsensidos); /** FUNCTIONS */ function onCellStabsensidosClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditStabsensidos(grid, record)}); RH.DeleteClick(e, function(){fnDeleteStabsensidos(grid, record)}); } function reloadStabsensidos(){ ds_stabsensidos.reload(); } function fnAddStabsensidos(){ var grid = gp_stabsensidos; wEntryStabsensidos(false, grid, null); } function fnEditStabsensidos(grid, record){ wEntryStabsensidos(true, grid, record); } function fnDeleteStabsensidos(grid, record){ var url = BASE_URL + 'stabsensidos_controller/delete_stabsensidos'; var params = new Object({ idstabsensdos : record.data['idstabsensdos'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT STATUS ABSENSI DOSEN */ function wEntryStabsensidos(isUpdate, grid, record){ var winTitle = (isUpdate)?'Status Absensi Dosen (Edit)':'Status Absensi Dosen (Entry)'; /** DATA SOURCE GRUP STATUS ABSENSI DOSEN */ /*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 stabsensidos_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stabsensidos', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 200, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.kdstabsensidos', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmstabsensidos', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveStabsensidos(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wStabsensidos.close(); } }] }); var wStabsensidos = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stabsensidos_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStabsensidosForm(isUpdate, record); wStabsensidos.show(); /** FORM FUNCTIONS */ function setStabsensidosForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdstabsensidos'); RH.setCompValue('tf.frm.kdstabsensidos', record.data['kdstabsensidos']); RH.setCompValue('tf.frm.nmstabsensidos', record.data['nmstabsensidos']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveStabsensidos(){ var idForm = 'frm.stabsensidos'; var sUrl = BASE_URL +'stabsensidos_controller/insert_stabsensidos'; var sParams = new Object({ kdstabsensidos : RH.getCompValue('tf.frm.kdstabsensidos'), nmstabsensidos : RH.getCompValue('tf.frm.nmstabsensidos'), 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 +'stabsensidos_controller/update_stabsensidos'; sParams.idstabsensdos = record.data['idstabsensdos']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStabsensidos, msgWait, msgSuccess, msgFail, msgInvalid); } }