function pPekerjaanortu(){ var fields_pekerjaanortu = RH.storeFields('idpekerjaanortu','kdpekerjaanortu','nmpekerjaanortu','deskripsi'); var pageSize = 18; var ds_pekerjaanortu = RH.JsonStore({ url : BASE_URL + 'pekerjaanortu_controller/get_pekerjaanortu', fields : fields_pekerjaanortu, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_pekerjaanortu = RH.searchComp({ id : 'sb_pekerjaanortu', fields : ['kdpekerjaanortu:Kode','nmpekerjaanortu:Nama'], selected : 'nmpekerjaanortu', store : ds_pekerjaanortu }); // COLUMN MODEL var cm_pekerjaanortu = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: RH.h3('Kode'),width: 100, dataIndex: 'kdpekerjaanortu', sortable: true }, { header: RH.h3('Nama'), width: 300, dataIndex: 'nmpekerjaanortu', sortable: true }, { header: RH.h3('Deskripsi'), width: 300, dataIndex: 'deskripsi', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_pekerjaanortu = RH.GridPanel_T1({ ds: ds_pekerjaanortu, cm: cm_pekerjaanortu, singleSelect: true, searchComp: sb_pekerjaanortu, allowAdd: true, fnAdd: fnAddPekerjaanortu, pageSize: pageSize, cellclick: onCellPekerjaanortuClick }); var fp_pekerjaanortu = RH.GPContainer1({ title: 'Pekerjaan Orangtua', iconCls:'silk-house', gridPanel: gp_pekerjaanortu, }); SET_PAGE_CONTENT(fp_pekerjaanortu); /** FUNCTIONS */ function onCellPekerjaanortuClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditPekerjaanortu(grid, record)}); RH.DeleteClick(e, function(){fnDeletePekerjaanortu(grid, record)}); } function reloadPekerjaanortu(){ ds_pekerjaanortu.reload(); } function fnAddPekerjaanortu(){ var grid = gp_pekerjaanortu; wEntryPekerjaanortu(false, grid, null); } function fnEditPekerjaanortu(grid, record){ wEntryPekerjaanortu(true, grid, record); } function fnDeletePekerjaanortu(grid, record){ var url = BASE_URL + 'pekerjaanortu_controller/delete_pekerjaanortu'; var params = new Object({ idpekerjaanortu : record.data['idpekerjaanortu'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT PEKERJAAN ORANGTUA */ function wEntryPekerjaanortu(isUpdate, grid, record){ var winTitle = (isUpdate)?'Pekerjaan Orangtua (Edit)':'Pekerjaan Orangtua (Entry)'; /** DATA SOURCE GRUP PEKERJAAN 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 pekerjaanortu_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.pekerjaanortu', 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.kdpekerjaanortu', fieldLabel: 'Kode', width: 150, allowBlank: false, },{ id: 'tf.frm.nmpekerjaanortu', fieldLabel: 'Nama', width: 300, allowBlank: false, },{ xtype: 'textarea', id: 'ta.frm.deskripsi', fieldLabel: 'Deskripsi', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSavePekerjaanortu(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wPekerjaanortu.close(); } }] }); var wPekerjaanortu = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [pekerjaanortu_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setPekerjaanortuForm(isUpdate, record); wPekerjaanortu.show(); /** FORM FUNCTIONS */ function setPekerjaanortuForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdpekerjaanortu'); RH.setCompValue('tf.frm.kdpekerjaanortu', record.data['kdpekerjaanortu']); RH.setCompValue('tf.frm.nmpekerjaanortu', record.data['nmpekerjaanortu']); RH.setCompValue('ta.frm.deskripsi', record.data['deskripsi']); return; } } } function fnSavePekerjaanortu(){ var idForm = 'frm.pekerjaanortu'; var sUrl = BASE_URL +'pekerjaanortu_controller/insert_pekerjaanortu'; var sParams = new Object({ kdpekerjaanortu : RH.getCompValue('tf.frm.kdpekerjaanortu'), nmpekerjaanortu : RH.getCompValue('tf.frm.nmpekerjaanortu'), 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 +'pekerjaanortu_controller/update_pekerjaanortu'; sParams.idpekerjaanortu = record.data['idpekerjaanortu']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wPekerjaanortu, msgWait, msgSuccess, msgFail, msgInvalid); } }