function pPendidikanortu(){ var fields_pendidikanortu = RH.storeFields('idpendidikanortu','kdpendidikanortu','nmpendidikanortu','deskripsi'); var pageSize = 18; var ds_pendidikanortu = RH.JsonStore({ url : BASE_URL + 'pendidikanortu_controller/get_pendidikanortu', fields : fields_pendidikanortu, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_pendidikanortu = RH.searchComp({ id : 'sb_pendidikanortu', fields : ['kdpendidikanortu:Kode','nmpendidikanortu:Nama'], selected : 'nmpendidikanortu', store : ds_pendidikanortu }); // COLUMN MODEL var cm_pendidikanortu = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdpendidikanortu', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmpendidikanortu', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_pendidikanortu = RH.GridPanel_T1({ ds: ds_pendidikanortu, cm: cm_pendidikanortu, singleSelect: true, searchComp: sb_pendidikanortu, allowAdd: true, fnAdd: fnAddPendidikanortu, pageSize: pageSize, cellclick: onCellPendidikanortuClick }); var fp_pendidikanortu = RH.GPContainer1({ title: 'Pendidikan Orangtua', iconCls:'silk-house', gridPanel: gp_pendidikanortu, }); SET_PAGE_CONTENT(fp_pendidikanortu); /** FUNCTIONS */ function onCellPendidikanortuClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditPendidikanortu(grid, record)}); RH.DeleteClick(e, function(){fnDeletePendidikanortu(grid, record)}); } function reloadPendidikanortu(){ ds_pendidikanortu.reload(); } function fnAddPendidikanortu(){ var grid = gp_pendidikanortu; wEntryPendidikanortu(false, grid, null); } function fnEditPendidikanortu(grid, record){ wEntryPendidikanortu(true, grid, record); } function fnDeletePendidikanortu(grid, record){ var url = BASE_URL + 'pendidikanortu_controller/delete_pendidikanortu'; var params = new Object({ idpendidikanortu : record.data['idpendidikanortu'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT PENDIDIKAN ORANGTUA */ function wEntryPendidikanortu(isUpdate, grid, record){ var winTitle = (isUpdate)?'Pendidikan Orangtua (Edit)':'Pendidikan Orangtua (Entry)'; /** DATA SOURCE GRUP PENDIDIKAN ORANGTUA */ /*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 pendidikanortu_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.pendidikanortu', 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.kdpendidikanortu', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmpendidikanortu', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSavePendidikanortu(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wPendidikanortu.close(); } }] }); var wPendidikanortu = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [pendidikanortu_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setPendidikanortuForm(isUpdate, record); wPendidikanortu.show(); /** FORM FUNCTIONS */ function setPendidikanortuForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdpendidikanortu'); RH.setCompValue('tf.frm.kdpendidikanortu', record.data['kdpendidikanortu']); RH.setCompValue('tf.frm.nmpendidikanortu', record.data['nmpendidikanortu']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSavePendidikanortu(){ var idForm = 'frm.pendidikanortu'; var sUrl = BASE_URL +'pendidikanortu_controller/insert_pendidikanortu'; var sParams = new Object({ kdpendidikanortu : RH.getCompValue('tf.frm.kdpendidikanortu'), nmpendidikanortu : RH.getCompValue('tf.frm.nmpendidikanortu'), 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 +'pendidikanortu_controller/update_pendidikanortu'; sParams.idpendidikanortu = record.data['idpendidikanortu']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wPendidikanortu, msgWait, msgSuccess, msgFail, msgInvalid); } }