function pKlsparalel(){ var fields_paralel = RH.storeFields('klsparalel','',''); var pageSize = 18; var ds_paralel = RH.JsonStore({ url : BASE_URL + 'klsparalel_controller/get_klsparalel', fields : fields_paralel, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_paralel = RH.searchComp({ id : 'sb_paralel', fields : ['klsparalel:Kelas Paralel'], selected : 'klsparalel', store : ds_paralel }); // COLUMN MODEL var cm_paralel = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kelas Paralel'),width: 100, dataIndex: 'klsparalel', sortable: true }, /*RH.EditColumn(),*/ RH.DeleteColumn() ] ); /** THE GRID */ var gp_paralel = RH.GridPanel_T1({ ds: ds_paralel, cm: cm_paralel, singleSelect: true, searchComp: sb_paralel, allowAdd: true, fnAdd: fnAddParalel, pageSize: pageSize, cellclick: onCellParalelClick }); var fp_paralel = RH.GPContainer1({ title: 'Kelas Paralel', iconCls:'silk-house', gridPanel: gp_paralel, }); SET_PAGE_CONTENT(fp_paralel); /** FUNCTIONS */ function onCellParalelClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditParalel(grid, record)}); RH.DeleteClick(e, function(){fnDeleteParalel(grid, record)}); } function reloadParalel(){ ds_paralel.reload(); } function fnAddParalel(){ var grid = gp_paralel; wEntryParalel(false, grid, null); } function fnEditParalel(grid, record){ wEntryParalel(true, grid, record); } function fnDeleteParalel(grid, record){ var url = BASE_URL + 'klsparalel_controller/delete_klsparalel'; var params = new Object({ klsparalel : record.data['klsparalel'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT JAM */ function wEntryParalel(isUpdate, grid, record){ var winTitle = (isUpdate)?'Kelas Paralel (Edit)':'Kelas Paralel (Entry)'; /** /** FORM ENTRY/EDIT MATA-KULIAH */ var paralel_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.paralel', buttonAlign: 'left', labelWidth: 170, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 100, width: 300, layout: 'form', frame: false, defaultType:'textfield', items: [ { xtype: 'textfield', id: 'tf.form.paralel', name: 'tf.form.paralel', fieldLabel: 'Kelas Paralel (min. 2, max. 2)', width: 50, maxLength : 2, minLength : 2, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveParalel(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wParalel.close(); } }] }); var wParalel = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [paralel_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setParalelForm(isUpdate, record); wParalel.show(); /** FORM FUNCTIONS */ function setParalelForm(isUpdate, record){ if(isUpdate){ if(record != null){ var klsparalel; klsparalel = record.data['klsparalel']; RH.setCompValue('tf.form.paralel', klsparalel); return; } } } function fnSaveParalel(){ var idForm = 'frm.paralel'; var sUrl = BASE_URL +'klsparalel_controller/insert_klsparalel'; var sParams = new Object({ klsparalel : RH.getCompValue('tf.form.paralel'), }); 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 +'klsparalel_controller/update_klsparalel'; sParams.klsparalel = record.data['klsparalel']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wParalel, msgWait, msgSuccess, msgFail, msgInvalid); } }