function pThnakademik(){ var fields_thnakademik = RH.storeFields('idthnakademik','kdthnakademik','nmthnakademik','deskripsi'); var pageSize = 18; var ds_thnakademik = RH.JsonStore({ url : BASE_URL + 'thnakademik_controller/get_thnakademik', fields : fields_thnakademik, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_thnakademik = RH.searchComp({ id : 'sb_thnakademik', fields : ['kdthnakademik:Kode','nmthnakademik:Nama'], selected : 'nmthnakademik', store : ds_thnakademik }); // COLUMN MODEL var cm_thnakademik = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdthnakademik', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmthnakademik', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_thnakademik = RH.GridPanel_T1({ ds: ds_thnakademik, //title: 'Tahun Akademik', iconCls: '', cm: cm_thnakademik, singleSelect: true, searchComp: sb_thnakademik, allowAdd: true, fnAdd: fnAddThnAkademik, pageSize: pageSize, cellclick: onCellThnAkademikClick }); var fp_thnakademik = RH.GPContainer1({ title: 'Tahun Akademik', iconCls:'silk-calendar', gridPanel: gp_thnakademik, }); SET_PAGE_CONTENT(fp_thnakademik); /** FUNCTIONS */ function onCellThnAkademikClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditThnAkademik(grid, record)}); RH.DeleteClick(e, function(){fnDeleteThnAkademik(grid, record)}); } function reloadThnAkademik(){ ds_thnakademik.reload(); } function fnAddThnAkademik(){ var grid = gp_thnakademik; wEntryThnakademik(false, grid, null); } function fnEditThnAkademik(grid, record){ wEntryThnakademik(true, grid, record); } function fnDeleteThnAkademik(grid, record){ var url = BASE_URL + 'thnakademik_controller/delete_thnakademik'; var params = new Object({ kdthnakademik : record.data['kdthnakademik'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT TAHUN AKADEMIK */ function wEntryThnakademik(isUpdate, grid, record){ var winTitle = (isUpdate)?'Tahun Akademik (Edit)':'Tahun Akademik (Entry)'; /** DATA SOURCE GRUP TAHUN AKADEMIK */ /*var ds_grupruangan = 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 thnakademik_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.thnakademik', 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.kdthnakademik', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmthnakademik', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveThnAkademik(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wThnAkademik.close(); } }] }); var wThnAkademik = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [thnakademik_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setThnAkademikForm(isUpdate, record); wThnAkademik.show(); /** FORM FUNCTIONS */ function setThnAkademikForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ RH.disableComp('tf.frm.kdthnakademik'); RH.setCompValue('tf.frm.kdthnakademik', record.data['kdthnakademik']); RH.setCompValue('tf.frm.nmthnakademik', record.data['nmthnakademik']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSaveThnAkademik(){ var idForm = 'frm.thnakademik'; var sUrl = BASE_URL +'thnakademik_controller/insert_thnakademik'; var sParams = new Object({ kdthnakademik : RH.getCompValue('tf.frm.kdthnakademik'), nmthnakademik : RH.getCompValue('tf.frm.nmthnakademik'), 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 +'thnakademik_controller/update_thnakademik'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wThnAkademik, msgWait, msgSuccess, msgFail, msgInvalid); } }