function pSetipk(){ var fields_setipk = RH.storeFields('idsetipk','ipkdari','ipksampai','keterangan'); var pageSize = 18; var ds_setipk = RH.JsonStore({ url : BASE_URL + 'setipk_controller/get_setipk', fields : fields_setipk, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_setipk = RH.searchComp({ id : 'sb_setipk', fields : ['ipkdari:IPK Dari','ipksampai:IPK Sampai','keterangan:Keterangan'], selected : 'ipksampai', store : ds_setipk }); // COLUMN MODEL var cm_setipk = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('IPK Dari'),width: 150, dataIndex: 'ipkdari', sortable: true }, { header: RH.h3('IPK Sampai'), width: 150, dataIndex: 'ipksampai', sortable: true }, { header: RH.h3('Keterangan'), width: 300, dataIndex: 'keterangan', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_setipk = RH.GridPanel_T1({ ds: ds_setipk, cm: cm_setipk, singleSelect: true, searchComp: sb_setipk, allowAdd: true, fnAdd: fnAddSetipk, pageSize: pageSize, cellclick: onCellSetipkClick }); var fp_setipk = RH.GPContainer1({ title: 'Set IPK', iconCls:'silk-house', gridPanel: gp_setipk, }); SET_PAGE_CONTENT(fp_setipk); /** FUNCTIONS */ function onCellSetipkClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditSetipk(grid, record)}); RH.DeleteClick(e, function(){fnDeleteSetipk(grid, record)}); } function reloadSetipk(){ ds_setipk.reload(); } function fnAddSetipk(){ var grid = gp_setipk; wEntrySetipk(false, grid, null); } function fnEditSetipk(grid, record){ wEntrySetipk(true, grid, record); } function fnDeleteSetipk(grid, record){ var url = BASE_URL + 'setipk_controller/delete_setipk'; var params = new Object({ idsetipk : record.data['idsetipk'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT SET IPK */ function wEntrySetipk(isUpdate, grid, record){ var winTitle = (isUpdate)?'Set IPK (Edit)':'Set IPK (Entry)'; /** DATA SOURCE GRUP SET IPK */ /*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 setipk_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.setipk', 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.ipkdari', fieldLabel: 'IPK Dari', width: 150, allowBlank: false, },{ id: 'tf.frm.ipksampai', fieldLabel: 'IPK Sampai', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.keterangan', fieldLabel: 'Keterangan', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveSetipk(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wSetipk.close(); } }] }); var wSetipk = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [setipk_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setSetipkForm(isUpdate, record); wSetipk.show(); /** FORM FUNCTIONS */ function setSetipkForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.ipkdari'); RH.setCompValue('tf.frm.ipkdari', record.data['ipkdari']); RH.setCompValue('tf.frm.ipksampai', record.data['ipksampai']); RH.setCompValue('ta.frm.keterangan', record.data['keterangan']); return; } } } function fnSaveSetipk(){ var idForm = 'frm.setipk'; var sUrl = BASE_URL +'setipk_controller/insert_setipk'; var sParams = new Object({ ipkdari : RH.getCompValue('tf.frm.ipkdari'), ipksampai : RH.getCompValue('tf.frm.ipksampai'), keterangan : RH.getCompValue('ta.frm.keterangan'), }); 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 +'setipk_controller/update_setipk'; sParams.idsetipk = record.data['idsetipk']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSetipk, msgWait, msgSuccess, msgFail, msgInvalid); } }