function pSemester(){ var ds_jsemester = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_jsemester ', method: 'POST' }), root: 'data', autoLoad: true, fields: [{ name: "idjnssemester" }, { name: "nmjnssemester" }] }); var StoresObj = new Object({ jsemester: ds_jsemester }); var fields_semester = RH.storeFields('idsemester','kdsemester','nmsemester','deskripsi', 'idjnssemester','tingkat','nmjnssemester'); var pageSize = 18; var ds_semester = RH.JsonStore({ url : BASE_URL + 'semester_controller/get_semester', fields : fields_semester, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_semester = RH.searchComp({ id : 'sb_semester', fields : ['kdsemester:Kode','nmsemester:Nama','tingkat:Tingkat','nmjnssemester:Jenis Semester'], selected : 'nmsemester', store : ds_semester }); // COLUMN MODEL var cm_semester = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('ID Semester'),width: 100, dataIndex: 'idsemester', sortable: true }, { header: RH.h3('Kode'), width: 120, dataIndex: 'kdsemester', sortable: true }, { header: RH.h3('Nama'), width: 120, dataIndex: 'nmsemester', sortable: true }, { header: RH.h3('Tingkat'), width: 120, dataIndex: 'tingkat', sortable: true }, { header: RH.h3('Jenis Semester'), width: 120, dataIndex: 'nmjnssemester', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_semester = RH.GridPanel_T1({ ds: ds_semester, //title: 'Semester', iconCls: '', cm: cm_semester, singleSelect: true, searchComp: sb_semester, allowAdd: true, fnAdd: fnAddSemester, pageSize: pageSize, cellclick: onCellSemester }); var fp_semester = RH.GPContainer1({ title: 'Semester', iconCls:'silk-calendar', gridPanel: gp_semester, }); SET_PAGE_CONTENT(fp_semester); /** FUNCTIONS */ function onCellSemester(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditSemester(grid, record)}); RH.DeleteClick(e, function(){fnDeleteSemester(grid, record)}); } function reloadSemester(){ ds_semester.reload(); } function fnAddSemester(){ var grid = gp_semester; wEntrySemester(false, grid, null, StoresObj); } function fnEditSemester(grid, record){ wEntrySemester(true, grid, record, StoresObj); } function fnDeleteSemester(grid, record){ var url = BASE_URL + 'semester_controller/delete_semester'; var params = new Object({ idsemester : record.data['idsemester'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT Semester */ function wEntrySemester(isUpdate, grid, record, StoresObj){ var winTitle = (isUpdate)?'Semester (Edit)':'Semester (Entry)'; /** FORM ENTRY/EDIT MATA-KULIAH */ var ds_jsemester = StoresObj.jsemester; var semester_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.semester', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 300, width: 500, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'idsemester', fieldLabel: 'ID Semester', width: 150, allowBlank: false, },{ id: 'kdsemester', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'nmsemester', fieldLabel: 'Nama', width: 150, allowBlank: false, },{ id: 'tingkat', fieldLabel: 'Tingkat', width: 150, allowBlank: false, },{ xtype: 'combo', id: 'h_idjnssemester', fieldLabel: 'Jenis Semester', store: ds_jsemester, triggerAction: 'all', valueField: 'idjnssemester', displayField: 'nmjnssemester', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 300, allowBlank: false, editable:false, },{ xtype: 'textarea', id: 'deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveThnAkademik(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wSemester.close(); } }] }); var wSemester = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [semester_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setSemesterForm(isUpdate, record); wSemester.show(); /** FORM FUNCTIONS */ function setSemesterForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ RH.disableComp('idsemester'); RH.setCompValue('idsemester', record.data['idsemester']); RH.setCompValue('kdsemester', record.data['kdsemester']); RH.setCompValue('nmsemester', record.data['nmsemester']); RH.setCompValue('deskripsi', record.data['deskripsi']); RH.setCompValue('tingkat', record.data['tingkat']); RH.setCompValue('h_idjnssemester', record.data['idjnssemester']); return; } } } function fnSaveThnAkademik(){ var idForm = 'frm.semester'; var sUrl = BASE_URL +'semester_controller/insert_semester'; var sParams = new Object({ idsemester : RH.getCompValue('idsemester'), kdsemester : RH.getCompValue('kdsemester'), nmsemester : RH.getCompValue('nmsemester'), deskripsi : RH.getCompValue('deskripsi'), tingkat : RH.getCompValue('tingkat'), idjnssemester : RH.getCompValue('h_idjnssemester'), }); 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 +'semester_controller/update_semester'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wSemester, msgWait, msgSuccess, msgFail, msgInvalid); } }