function pStdosen(){ var ds_stsemester = store_stsmt(); var ds_prodi = store_prodireg(); var wAddEditStoresObj = new Object({ prodi: ds_prodi, stsemester:ds_stsemester}); var fields_stdosen = RH.storeFields('idstdossemester','kdprodi','nidu','kdstsemester','kdjenjangstudi','kdstaktivitasdosen','keterangan','nmdosdgngelar'); var pageSize = 18; var ds_stdosen = RH.JsonStore({ url : BASE_URL + 'stdosen_controller/get_stdosen', fields : fields_stdosen, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_stdosen = RH.searchComp({ id : 'sb_stdosen', fields : ['nidu:NIDU','nmdosen:Nama Dosen'], selected : 'nidu', store : ds_stdosen }); // COLUMN MODEL var cm_stdosen = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'Semester Pelaporan',width: 150, dataIndex: 'kdstsemester', sortable: true }, { header: 'Jenjang Studi',width: 150, dataIndex: 'kdjenjangstudi', sortable: true }, { header: 'Program Studi', width: 200, dataIndex: 'nmprodi', sortable: true }, { header: 'NIDU', width: 100, dataIndex: 'nidu', sortable: true }, { header: 'Nama Dosen', width: 150, dataIndex: 'nmdosdgngelar', sortable: true }, { header: 'Status Dosen', width: 100, dataIndex: 'kdstaktivitasdosen', sortable: true }, { header: 'Keterangan', width: 200, dataIndex: 'keterangan', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_stdosen = RH.GridPanel_T1({ ds: ds_stdosen, cm: cm_stdosen, singleSelect: true, searchComp: sb_stdosen, allowAdd: true, fnAdd: fnAddStdosen, pageSize: pageSize, cellclick: onCellStdosenClick }); var fp_stdosen = RH.GPContainer1({ title: 'Status Dosen', iconCls:'silk-house', gridPanel: gp_stdosen, }); SET_PAGE_CONTENT(fp_stdosen); /** FUNCTIONS */ function onCellStdosenClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditStdosen(grid, record)}); RH.DeleteClick(e, function(){fnDeleteStdosen(grid, record)}); } function reloadStdosen(){ ds_stdosen.reload(); } function fnAddStdosen(){ var grid = gp_stdosen; wEntryStdosen(false, grid, null, wAddEditStoresObj); } function fnEditStdosen(grid, record){ wEntryStdosen(true, grid, record, wAddEditStoresObj); } function fnDeleteStdosen(grid, record){ var url = BASE_URL + 'stdosen_controller/delete_stdosen'; var params = new Object({ idstdossemester : record.data['idstdossemester'] }); RH.deleteGridRecord(url, params, grid ); } } /** WIN - FORM ENTRY/EDIT STATUS DOSEN */ function wEntryStdosen(isUpdate, grid, record, wAddEditStoresObj){ var winTitle = (isUpdate)?'Status Dosen (Edit)':'Status Dosen (Entry)'; /** DATA SOURCE GRUP STATUS DOSEN */ var ds_prodi = wAddEditStoresObj.prodi; var ds_stsemester = wAddEditStoresObj.stsemester; // Status Aktivitas Dosen var ds_staktivdos = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_staktivdos ', method: 'POST' }), autoLoad: true, root: 'data', fields: f2Fields, }); // Jenjang Studi var ds_jenjangstudi = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_jenjangstudi ', method: 'POST' }), autoLoad: true, root: 'data', fields: f2Fields, }); /** FORM ENTRY/EDIT MATA-KULIAH */ var stdosen_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stdosen', buttonAlign: 'left', labelWidth: 150, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 300, width: 700, layout: 'form', frame: false, defaultType:'textfield', items: [ { xtype: 'combo', id: 'cb.frm.kdstsemester', fieldLabel: 'Semester Pelaporan', allowBlank: false, editable:false, store: ds_stsemester, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 200, },{ xtype: 'combo', id: 'cb.frm.kdjenjangstudi', fieldLabel: 'Jenjang Studi', store: ds_jenjangstudi, triggerAction: 'all', valueField: 'kode', displayField: 'nama', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 200, },{ xtype: 'combo', id: 'cb.frm.kdprodi', fieldLabel: 'Program Studi', allowBlank: false, editable:false, store: ds_prodi, triggerAction: 'all', valueField: 'kdprodi', displayField: 'lnmprodi', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 350, },{ xtype: 'container',//'fieldcontainer', fieldLabel: 'NIDU', layout: 'hbox', //combineErrors: true, defaultType: 'textfield', defaults: { hideLabel: true }, items: [ { id: 'tf.frm.nidu', width: 80, readOnly: true } , { id: 'tf.frm.nmdosen', margins: '0 0 0 6', width: 320, readOnly: true } , { xtype: 'button', id: 'btnpt', iconCls: 'silk-find', margins: '0 0 0 6', width: 30, handler: function() { wLookup(lu_nidu, 'Ketua Program Studi','tf.frm.nidu','tf.frm.nmdosen');} }] },{ xtype: 'combo', id: 'cb.frm.kdstaktivitasdosen', fieldLabel: 'Status Dosen', allowBlank: false, editable:false, store: ds_staktivdos, triggerAction: 'all', valueField: 'kode', displayField: 'nama', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 200, },{ xtype: 'textarea', id: 'ta.frm.keterangan', fieldLabel: 'Keterangan', width: 300, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveStdosen(); } }, { text: 'Kembali', iconCls:'silk-arrow-undo', handler: function() { wStdosen.close(); } }] }); var wStdosen = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stdosen_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStdosenForm(isUpdate, record); wStdosen.show(); /** FORM FUNCTIONS */ function setStdosenForm(isUpdate, record){ var kdprodi = RH.getCompValue('cb.prodi-matkul', true); if(isUpdate){ if(record != null){ //RH.disableComp('tf.frm.kdprodi'); RH.setCompValue('cb.frm.kdstsemester', record.data['kdstsemester']); RH.setCompValue('cb.frm.kdjenjangstudi', record.data['kdjenjangstudi']); RH.setCompValue('cb.frm.kdprodi', record.data['kdprodi']); RH.setCompValue('tf.frm.nidu', record.data['nidu']); RH.setCompValue('tf.frm.nmdosen', record.data['nmdosen']); RH.setCompValue('cb.frm.kdstaktivitasdosen', record.data['kdstaktivitasdosen']); RH.setCompValue('ta.frm.keterangan', record.data['keterangan']); return; } } } function fnSaveStdosen(){ var idForm = 'frm.stdosen'; var sUrl = BASE_URL +'stdosen_controller/insert_stdosen'; var sParams = new Object({ kdstsemester : RH.getCompValue('cb.frm.kdstsemester'), kdjenjangstudi : RH.getCompValue('cb.frm.kdjenjangstudi'), kdprodi : RH.getCompValue('cb.frm.kdprodi'), nidu : RH.getCompValue('tf.frm.nidu'), nmdosen : RH.getCompValue('tf.frm.nmdosen'), kdstaktivitasdosen : RH.getCompValue('cb.frm.kdstaktivitasdosen'), keterangan : RH.getCompValue('ta.frm.keterangan'), }); 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 +'stdosen_controller/update_stdosen'; sParams.idstdossemester = record.data['idstdossemester']; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStdosen, msgWait, msgSuccess, msgFail, msgInvalid); } }