function pJsemester(){ var fields_jsemester = RH.storeFields('idjnssemester','kdjnssemester','nmjnssemester','deskripsi'); var pageSize = 18; var ds_jsemester = RH.JsonStore({ url : BASE_URL + 'jnssemester_controller/get_jsemester', fields : fields_jsemester, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_jsemester = RH.searchComp({ id : 'sb_jsemester', fields : ['kdjnssemester:Kode','nmjnssemester:Nama'], selected : 'nmjnssemester', store : ds_jsemester }); // COLUMN MODEL var cm_jsemester = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdjnssemester', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmjnssemester', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_jsemester = RH.GridPanel_T1({ ds: ds_jsemester, cm: cm_jsemester, singleSelect: true, searchComp: sb_jsemester, allowAdd: true, fnAdd: fnAddJsemester, pageSize: pageSize, cellclick: onCellJsemesterClick }); var fp_jsemester = RH.GPContainer1({ title: 'Jenis Semester', iconCls:'silk-house', gridPanel: gp_jsemester, }); SET_PAGE_CONTENT(fp_jsemester); /** FUNCTIONS */ function onCellJsemesterClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditJsemester(grid, record)}); RH.DeleteClick(e, function(){fnDeleteJsemester(grid, record)}); } function reloadJsemester(){ ds_jsemester.reload(); } function fnAddJsemester(){ var grid = gp_jsemester; wEntryJsemester(false, grid, null); } function fnEditJsemester(grid, record){ wEntryJsemester(true, grid, record); } function fnDeleteJsemester(grid, record){ var url = BASE_URL + 'jnssemester_controller/delete_jsemester'; var params = new Object({ idjnssemester : record.data['idjnssemester'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS SEMESTER */ function wEntryJsemester(isUpdate, grid, record){ var winTitle = (isUpdate)?'Jenis Semester (Edit)':'Jenis Semester (Entry)'; /** DATA SOURCE GRUP JENIS SEMESTER */ /*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 jsemester_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.jsemester', 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.kdjnssemester', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmjnssemester', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveJsemester(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wJsemester.close(); } }] }); var wJsemester = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [jsemester_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setJsemesterForm(isUpdate, record); wJsemester.show(); /** FORM FUNCTIONS */ function setJsemesterForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnssemester'); RH.setCompValue('tf.frm.kdjnssemester', record.data['kdjnssemester']); RH.setCompValue('tf.frm.nmjnssemester', record.data['nmjnssemester']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveJsemester(){ var idForm = 'frm.jsemester'; var sUrl = BASE_URL +'jnssemester_controller/insert_jsemester'; var sParams = new Object({ kdjnssemester : RH.getCompValue('tf.frm.kdjnssemester'), nmjnssemester : RH.getCompValue('tf.frm.nmjnssemester'), 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 +'jnssemester_controller/update_jsemester'; sParams.idjnssemester = record.data['idjnssemester']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wJsemester, msgWait, msgSuccess, msgFail, msgInvalid); } }