function pTipekelas(){ var fields_tpkls = RH.storeFields('idtipekelas','kdtipekelas','nmtipekelas'); var pageSize = 20; var ds_tpkls = RH.JsonStore({ url : BASE_URL + 'tipekelas_controller/get_tipekelas', fields : fields_tpkls, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_tpkls = RH.searchComp({ id : 'sb_tpkls', fields : ['kdtipekelas:Kode Tipe Kelas','nmtipekelas:Nama Tipe Kelas'], selected : 'nmtipekelas', store : ds_tpkls }); // COLUMN MODEL var cm_tpkls = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode Tipe Kelas'), width: 150, dataIndex: 'kdtipekelas', sortable: true }, { header: RH.h3('Nama Tipe Kelas'), width: 150, dataIndex: 'nmtipekelas', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_tpkls = RH.GridPanel_T1({ ds: ds_tpkls, cm: cm_tpkls, singleSelect: true, searchComp: sb_tpkls, allowAdd: true, fnAdd: fnAddTpkls, pageSize: pageSize, cellclick: onCellTpklsClick }); var fp_tpkls = RH.GPContainer1({ title: 'Tipe Kelas', iconCls:'silk-house', gridPanel: gp_tpkls, }); SET_PAGE_CONTENT(fp_tpkls); /** FUNCTIONS */ function onCellTpklsClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditTpkls(grid, record)}); RH.DeleteClick(e, function(){fnDeleteTpkls(grid, record)}); } function reloadTpkls(){ ds_tpkls.reload(); } function fnAddTpkls(){ var grid = gp_tpkls; wEntryTpkls(false, grid, null); } function fnEditTpkls(grid, record){ wEntryTpkls(true, grid, record); } function fnDeleteTpkls(grid, record){ var url = BASE_URL + 'tipekelas_controller/delete_tipekelas'; var params = new Object({ idtipekelas : record.data['idtipekelas'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JENIS SLTA */ function wEntryTpkls(isUpdate, grid, record){ var winTitle = (isUpdate)?'Tipe Kelas (Edit)':'Tipe Kelas (Entry)'; /** DATA SOURCE GRUP JENIS SLTA */ /*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 tpkls_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.tpkls', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 150, width: 400, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'tf.frm.idtipekelas', fieldLabel: 'ID Tipe Kelas', hidden: true, },{ id: 'tf.frm.kdtipekelas', fieldLabel: 'Kode Tipe Kelas', width: 200, allowBlank: false, },{ id: 'ta.frm.nmtipekelas', fieldLabel: 'Nama Tipe Kelas', width: 200, allowBlank: false, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveTpkls(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wTpkls.close(); } }] }); var wTpkls = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [tpkls_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setTpklsForm(isUpdate, record); wTpkls.show(); /** FORM FUNCTIONS */ function setTpklsForm(isUpdate, record){ //var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdjnsslta'); RH.setCompValue('tf.frm.idtipekelas', record.data['idtipekelas']); RH.setCompValue('tf.frm.kdtipekelas', record.data['kdtipekelas']); RH.setCompValue('ta.frm.nmtipekelas', record.data['nmtipekelas']); return; } } } function fnSaveTpkls(){ var idForm = 'frm.tpkls'; var sUrl = BASE_URL +'tipekelas_controller/insert_tipekelas'; var sParams = new Object({ //kdjnsslta : RH.getCompValue('tf.frm.kdjnsslta'), kdtipekelas : RH.getCompValue('tf.frm.kdtipekelas'), nmtipekelas : RH.getCompValue('ta.frm.nmtipekelas'), }); 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 +'tipekelas_controller/update_tipekelas'; sParams.idtipekelas = record.data['idtipekelas']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wTpkls, msgWait, msgSuccess, msgFail, msgInvalid); } }