function mappingruanganpmb() { var nopmbselect; var ds_jadwalpmb = store_jadwalpmb(); var ds_ruangan = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'pendaftaran/c_mappingruanganpmb/get_ruanganpriv', method: 'POST' }), totalProperty: 'results', root: 'data', autoLoad: true, fields: [{ name: 'idruangan', mapping: 'idruangan' },{ name: 'nmruangan', mapping: 'nmruangan' }] }); var ds_grid = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'pendaftaran/c_mappingruanganpmb/get_pmbmapping', method: 'POST' }), root: 'data', totalProperty: 'results', autoLoad: false, fields: [{ name: 'nopmb' } , { name: 'nama' } , { name: 'kdjk' } , { name: 'tmpttgllhr' } , { name: 'nmstmskmhs' } , { name: 'prodi1' } , { name: 'idruangan' }] }); function render_ruangan(value) { var fValue = ''; var index = ds_ruangan.find('idruangan', value); if(index != -1)//the record has been found { var record = ds_ruangan.getAt(index); fValue = record.data['nmruangan'];// } return fValue; } var sm_nya = new Ext.grid.CheckboxSelectionModel({ }); var cm = new Ext.grid.ColumnModel({ defaults: { sortable: true }, columns: [sm_nya, new Ext.grid.RowNumberer({width: 35}), { header: RH.h3('No.PMB'), width: 100, dataIndex: 'nopmb', align: 'center', sortable: true }, { header: RH.h3('Nama'), width: 200, dataIndex: 'nama', sortable: true }, { header: RH.h3('(L/P)'), width: 50, dataIndex: 'kdjk', align: 'center', sortable: true }, { header: RH.h3('Tempat, Tgl.Lahir'), width: 150, dataIndex: 'tmpttgllhr', sortable: true }, { header: RH.h3('Status Pendaftar'), width: 150, dataIndex: 'nmstmskmhs', sortable: true }, { header: RH.h3('Prodi Pilihan 1'), width: 250, dataIndex: 'prodi1', sortable: true }, { header: RH.h3('Tempat / Ruangan'), width: 250, dataIndex: 'idruangan', sortable: true, renderer: render_ruangan, editor: { xtype: 'combo', allowBlank: true, store: ds_ruangan, name: 'cmbruangan', triggerAction: 'all', id: 'cmbruangan', valueField: 'idruangan', displayField: 'nmruangan', forceSelection: true, submitValue: true, hiddenName: 'h_cmbruangan', listeners: { select: function(cb, record) { var rec = (record.data.idruangan) ? record.data.idruangan:""; var arr = nopmbselect + 'x' + rec + 'x'; update_ruangan(arr); } }, typeAhead: true, mode: 'local', emptyText: 'Pilih Tempat / Ruangan...', selectOnFocus: true } }] }); var vw = new Ext.grid.GridView({ emptyText: '< No Data To Display >' }); var cari_data = [new Ext.ux.grid.Search({ iconCls: 'btn_search', minChars: 1, autoFocus: true, autoHeight: true, position: 'top', mode: 'local', width: 200 })]; var grid_nya = new Ext.grid.EditorGridPanel({ store: ds_grid, frame: true, height: 530, plugins: cari_data, id: 'grid_nya', buttonAlign: 'left', loadMask: true, defaults: { anchor: '-10' }, forceFit: true, tbar: [{ xtype: 'buttongroup', title: 'Pencarian', columns: 3, width: 800, defaults: { scale: 'small' }, items: [{ text: 'Jadwal PMB :' }, { xtype: 'combo', store: ds_jadwalpmb, name: 'kdjadwalpmb', id: 'kdjadwalpmb', triggerAction: 'all', editable: false, valueField: 'idjadwalpmb', displayField: 'nmjadwalpmb', forceSelection: true, submitValue: true, hiddenName: 'h_kdjadwalpmb', listeners: {}, typeAhead: true, mode: 'local', emptyText: 'Pilih...', selectOnFocus: true, width: 250 },{ xtype: 'button', text: ' Cari ', iconCls: 'silk-find', id: 'btn_data', width: 3, handler: function() { ds_grid.setBaseParam('idjadwalpmb', Ext.getCmp('kdjadwalpmb').getValue()); ds_grid.load(); } }] },'-',{ xtype: 'buttongroup', title: 'Penempatan', columns: 3, width: 800, defaults: { scale: 'small' }, items: [{ text: 'Tempat / Ruangan' },{ xtype: 'combo', allowBlank: true, store: ds_ruangan, name: 'cmbruanganselect', triggerAction: 'all', id: 'cmbruanganselect', valueField: 'idruangan', displayField: 'nmruangan', forceSelection: true, submitValue: true, hiddenName: 'h_cmbruanganselect', listeners: { select: function(cb, record) { } }, typeAhead: true, mode: 'local', emptyText: 'Pilih Tempat / Ruangan...', selectOnFocus: true },{ xtype: 'button', text: ' Update ', iconCls: 'silk-save', id: 'btn_data', width: 3, handler: function() { update_ruangan_all(); } }] },'->'], sm: sm_nya, vw: vw, autoScroll: true, cm: cm, clicksToEdit: 1, listeners: { rowclick: function rowclick(grid, rowIdx) { var rec = ds_grid.getAt(rowIdx); nopmbselect = rec.data["nopmb"]; } } }); var form_bp_general = new Ext.form.FormPanel({ id: 'form_bp_general', title: 'Mapping Ruangan Peserta USM TPA', region: 'center', buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, disabled: true, waitMsg: 'Waiting...', maskDisabled: false, monitorValid: true, items: [{ layout: 'form', border: false, items: [grid_nya] }] }); function update_ruangan_all(){ var m = grid_nya.getSelectionModel().getSelections(); var store = grid_nya.getStore(); var cmbruanganselect = RH.getCompValue('cmbruanganselect'); var arr = ''; var endarr = ';'; var recruangan = (cmbruanganselect) ? cmbruanganselect:""; if (m.length > 0) { for(var i=0; i< m.length; i++){ if (i+1==m.length){ endarr = ''; } arr = arr + m[i].data['nopmb'] + 'x' + recruangan + 'x' + endarr; } update_ruangan(arr); } else { Ext.MessageBox.alert("Informasi", "Silahkan Pilih Data"); } } function update_ruangan(arrparam){ var waitmsgupdate = Ext.MessageBox.wait('Update Data....', 'Info'); Ext.Ajax.request({ url: BASE_URL + 'pendaftaran/c_mappingruanganpmb/get_arraytoupdate', params: { arrparam: arrparam, }, success: function() { waitmsgupdate.hide(); ds_grid.reload(); }, failure: function() { waitmsgupdate.hide(); Ext.MessageBox.alert("Informasi", "Ubah Data Gagal"); } }); } get_content(form_bp_general); }