function pStabsenmhs(){ var fields_stabsenmhs = RH.storeFields('idstabsenmhs','kdstabsensimhs','nmstabsensimhs','deskripsi'); var pageSize = 18; var ds_stabsenmhs = RH.JsonStore({ url : BASE_URL + 'stabsenmhs_controller/get_stabsenmhs', fields : fields_stabsenmhs, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_stabsenmhs = RH.searchComp({ id : 'sb_stabsenmhs', fields : ['kdstabsensimhs:Kode','nmstabsensimhs:Nama'], selected : 'nmstabsensimhs', store : ds_stabsenmhs }); // COLUMN MODEL var cm_stabsenmhs = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdstabsensimhs', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmstabsensimhs', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_stabsenmhs = RH.GridPanel_T1({ ds: ds_stabsenmhs, cm: cm_stabsenmhs, singleSelect: true, searchComp: sb_stabsenmhs, allowAdd: true, fnAdd: fnAddStabsenmhs, pageSize: pageSize, cellclick: onCellStabsenmhsClick }); var fp_stabsenmhs = RH.GPContainer1({ title: 'Status Absensi Mahasiswa', iconCls:'silk-house', gridPanel: gp_stabsenmhs, }); SET_PAGE_CONTENT(fp_stabsenmhs); /** FUNCTIONS */ function onCellStabsenmhsClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditStabsenmhs(grid, record)}); RH.DeleteClick(e, function(){fnDeleteStabsenmhs(grid, record)}); } function reloadStabsenmhs(){ ds_stabsenmhs.reload(); } function fnAddStabsenmhs(){ var grid = gp_stabsenmhs; wEntryStabsenmhs(false, grid, null); } function fnEditStabsenmhs(grid, record){ wEntryStabsenmhs(true, grid, record); } function fnDeleteStabsenmhs(grid, record){ var url = BASE_URL + 'stabsenmhs_controller/delete_stabsenmhs'; var params = new Object({ idstabsenmhs : record.data['idstabsenmhs'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT STATUS ABSENSI MAHASISWA */ function wEntryStabsenmhs(isUpdate, grid, record){ var winTitle = (isUpdate)?'Status Absensi Mahasiswa (Edit)':'Status Absensi Mahasiswa (Entry)'; /** DATA SOURCE GRUP STATUS ABSENSI MAHASISWA */ /*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 stabsenmhs_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stabsenmhs', 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.kdstabsensimhs', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmstabsensimhs', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveStabsenmhs(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wStabsenmhs.close(); } }] }); var wStabsenmhs = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stabsenmhs_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStabsenmhsForm(isUpdate, record); wStabsenmhs.show(); /** FORM FUNCTIONS */ function setStabsenmhsForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdstabsensimhs'); RH.setCompValue('tf.frm.kdstabsensimhs', record.data['kdstabsensimhs']); RH.setCompValue('tf.frm.nmstabsensimhs', record.data['nmstabsensimhs']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveStabsenmhs(){ var idForm = 'frm.stabsenmhs'; var sUrl = BASE_URL +'stabsenmhs_controller/insert_stabsenmhs'; var sParams = new Object({ kdstabsensimhs : RH.getCompValue('tf.frm.kdstabsensimhs'), nmstabsensimhs : RH.getCompValue('tf.frm.nmstabsensimhs'), 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 +'stabsenmhs_controller/update_stabsenmhs'; sParams.idstabsenmhs = record.data['idstabsenmhs']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStabsenmhs, msgWait, msgSuccess, msgFail, msgInvalid); } }