function cKurikulumDet(idkurikulum, kdprodi, thnmasuk, storesObj){ /** STORE for GRID COLUMN EDITOR type COMBO */ var dcUrl = BASE_URL + 'data_controller/'; var obj2Fields = new Object([ { name: 'id' }, { name: 'kode' }, { name: 'nama' } ]); var obj4Fields = new Object([ { name: 'kode' }, { name: 'nama' } ]); var ds_lvlsyaratmk = RH.getCommonJsonStore(obj2Fields, dcUrl + 'get_lvlsyaratmk'); var ds_jnskurikulum = storesObj.jkurikulum; var ds_jnsmatkul = storesObj.jmatkul; //RH.warning(kdmk);return; var fields_kurdet = RH.storeFields('idsyaratmk','idkurikulum','kdmk','nmmkind', 'idsemester','jmlsks','jnskurikulum','jnsmk','idlvlsyaratmk', 'kdlvlsyaratmk','nmlvlsyaratmk','nilaihurufmin','bobotnilaimin'); var ds_kurdet = RH.JsonStore({ url : BASE_URL + 'kurikulumdet_controller/get_kurdet', fields : fields_kurdet, limit: 10, params: [ {key:'idkurikulum', value: idkurikulum}, {key:'kdprodi', value: kdprodi}, {key:'thnmasuk', value: thnmasuk} ], enableSearch: false, }); /** THE GRID COLUMN ===================================== */ /** RENDERER for GRID COLUMN */ function render_jkurikulum(value) { //RH.getRecordFieldValue(store, field, key, value) var val = RH.getRecordFieldValue(ds_jnskurikulum, 'nama', 'kode', value); return val; } function render_jmatkul(value) { var val = RH.getRecordFieldValue(ds_jnsmatkul, 'nama', 'kode', value); return val; } function render_lvlsyaratmk(value) { //RH.getRecordFieldValue(store, field, key, value) var val = RH.getRecordFieldValue(ds_lvlsyaratmk, 'nama', 'id', value); return RH.qtipEdit(val,'12px'); } /** FUNCTION for GRID COLUMN EDITOR */ var fnSelectDet = function(combo, record){ //The ID of THE combo must equals the field (key) to be updated var combId = combo.getId(); if (combId == 'idlvlsyaratmk') { var field1 = 'idlvlsyaratmk'; var value1 = record.data['id']; var field2 = 'kdlvlsyaratmk'; var value2 = record.data['kode']; } updateKurDet(field1, value1, field2, value2); }; /** GRID COLUMN MODEL */ var cm_kurdet = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), //for rows numbering { header:'idsyaratmk', dataIndex:'idsyaratmk', hidden:true, }, { header: RH.h3('Kode Mata Kuliah'), width:200, dataIndex: 'kdmk', sortable: true }, { header: RH.h3('Nama Mata Kuliah (Ind)'), width: 250, dataIndex: 'nmmkind', sortable: true, }, { header: RH.h3('Semester'), width: 66, dataIndex: 'idsemester' }, { header: RH.h3('Jumlah
SKS'), width: 70, dataIndex: 'jmlsks' }, { header: RH.h3('Jenis
Kurikulum'), width: 90, dataIndex: 'jnskurikulum', renderer: render_jkurikulum }, { header: RH.h3('Jenis
Mata Kuliah'), width: 110, dataIndex: 'jnsmk', renderer: render_jmatkul }, { header: RH.h3('Syarat Ke-'), width: 100, dataIndex: 'idlvlsyaratmk', renderer: render_lvlsyaratmk, editor: RH.getComboEditor('idlvlsyaratmk', false, ds_lvlsyaratmk, 'kode', 'nama', fnSelectDet), }, { header: RH.h3('Nilai Minimal'), width: 100, dataIndex: 'nilaihurufmin', }, RH.DeleteColumn() ] ); // Selection Model var sm_kurdet = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_kurdet = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** GRID PANEL */ var gp_kurdet = new Ext.grid.EditorGridPanel({ //PAKE EditorGridPanel ds: ds_kurdet, cm: cm_kurdet, sm: sm_kurdet, view: gv_kurdet, clicksToEdit: 1, //for cell editing (single click =1, dblclick=2) forceFit: true, //autoHeight: true, layout:'anchor', //autoSizeColumns: true, //autoExpandColumn: 'nmmkind', autoScroll:true, //enableColumnResize: true, columnLines: true, loadMask: true, tbar:[{ xtype: 'textfield', id: 'hidden.idsyaratmk', hidden:true, }, { text: 'Tambah', id: 'tb.add-kurdet', iconCls: 'silk-add', handler: function() { fnAddKurDet(); } }], bbar: new Ext.PagingToolbar({ store: ds_kurdet, displayInfo: true, pageSize: 10, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellKurDetClick } }); /** FUNCTIONS */ function onCellKurDetClick(grid, rowIndex, columnIndex, e) { var t = e.getTarget(); var record = grid.getStore().getAt(rowIndex); // Get the Record RH.setCompValue('hidden.idsyaratmk', record.data['idsyaratmk']); if (t.className == 'imgDelete') { fnDeleteKurDet(grid, record); return true; } return true; //back to ClickToEdit=1 } function fnAddKurDet(){ /*for DEBUG: RH.warning(RH.searchObj.params[0].name); return;*/ var kdprodi = RH.getCompValue('cb.prodi-kur', true); var thnmasuk = RH.getCompValue('cb.thmasuk-kur', true); var masterGrid = gp_kurdet; wLookupSyaratMatkul(masterGrid, idkurikulum, kdprodi, thnmasuk) } function fnDeleteKurDet(grid, record){ var url = BASE_URL + 'kurikulumdet_controller/delete_kurdet'; var params = new Object({ idsyaratmk : record.data['idsyaratmk'], }); RH.deleteGridRecord(url, params, grid ); } function updateKurDet(field1, value1, field2, value2){ Ext.Ajax.request({ url: BASE_URL + 'kurikulumdet_controller/update1field_kurdet', params: { idsyaratmk : RH.getCompValue('hidden.idsyaratmk',true), field1 : field1, value1 : value1, field2 : field2, value2 : value2, }, success: function() { ds_kurdet.reload(); }, failure: function() { Ext.Msg.alert("Info", "Ubah Data Gagal"); } }); } //RETURN THE GRID PANEL for DETAIL return gp_kurdet; } /** LOOKUP DOSEN FOR ADD SYARATMATKUL */ function wLookupSyaratMatkul(masterGrid, idkurikulum, kdprodi, thnmasuk){ /** DATA SOURCE */ var fieldsLookup = RH.storeFields('idkurikulum','kdmk','nmmkind','nmmkeng'); var ds_lookup = RH.JsonStore({ url : BASE_URL + 'kurikulumdet_controller/get_add_kurikulum', fields : fieldsLookup, limit : 20, params: [ {key:'kdprodi', value: kdprodi} ,{key:'thnmasuk', value: thnmasuk} ], enableSearch: true, }); //SEARCH COMPONENT var sb_lookup = RH.searchComp({ id: 'sb_lookup', fields : ['kdmk:Kode Mata Kuliah','nmmkind:Nama Mata Kuliah (Ind)','nmmkeng:Nama Mata Kuliah (Eng)'], selected : 'kdmk', store : ds_lookup, textWidth : 200 }); /** GRID LOOKUP MATA KULIAH */ // COLUMN MODEL var cm_lookup = new Ext.grid.ColumnModel([ { header: 'idkurikulum', dataIndex: 'idkurikulum',hidden: true }, { header: 'Kode Mata Kuliah',width: 150, dataIndex: 'kdmk', sortable: true }, { header: 'Nama Mata Kuliah (Indonesia)', width: 300, dataIndex: 'nmmkind', sortable: true }, { header: 'Nama Mata Kuliah (English)', width: 300, dataIndex: 'nmmkeng', sortable: true }] ); // Selection Model var sm_lookup = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_lookup = new Ext.grid.GridView({ emptyText: '< Belum ada Data >' }); var gp_lookup = new Ext.grid.GridPanel({ ds: ds_lookup, cm: cm_lookup, sm: sm_lookup, view: gv_lookup, forceFit: true, layout:'anchor', autoSizeColumns: true, //autoExpandColumn: 'nmmkind', autoScroll:true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, columnLines: true, loadMask: true, tbar:[sb_lookup], bbar: new Ext.PagingToolbar({ store: ds_lookup, displayInfo: true, pageSize: 18, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { rowdblclick: onRowDblClick } }); /** WIN LOOKUP MATA KULIAH */ var wLookup = new Ext.Window({ id: 'w.look-dos', title: 'Daftar Matakuliah', modal: true, layout: 'fit', width:720, height:400, items: [gp_lookup] }).show(); /** FUNCTIONS */ function onRowDblClick(grid, rowIdx) { var store = ds_lookup; var rec = store.getAt(rowIdx); var kdmk = rec.data['kdmk']; //INSERT NEW SYARATMATKUL REECORD (Dosen Pengampu) Ext.Ajax.request({ url: BASE_URL +'kurikulumdet_controller/insert_kurdet', method: 'POST', params: { idkurikulum : idkurikulum, kdmk : kdmk, }, waitMsg: 'Tunggu, sedang proses menyimpan...', success: function() { Ext.Msg.alert("Info", "Simpan Data Berhasil"); masterGrid.getStore().reload(); wLookup.close(); }, failure: function(result){ Ext.Msg.alert("Info", "Simpan Data Gagal"); } }); } }