function feederUpdateSmhs() { /** COMMON STORES */ var ds_mahasiswa = new Ext.data.JsonStore({ //static data fields: ['no', 'nim', 'nama', 'prodi', 'status', 'jenis_masuk', 'jk', 'ttl', 'agama', 'id_pd', 'id_reg_pd'], data: [] }); var uploadexcelform = new Ext.FormPanel({ fileUpload: true, width: 800, autoHeight: true, layout: 'form', bodyStyle: 'padding: 10px 10px 10px 10px;', labelWidth: 60, defaults: { allowBlank: false, msgTarget: 'side' }, items:[ { xtype:'compositefield', items:[ { xtype: 'fileuploadfield', id: 'excelmahasiswa', name: 'excelmahasiswa', emptyText: 'Upload data mahasiswa (excel)', width:300, fieldLabel: 'File ', buttonText: ' Browse ', },{ xtype:'button', text:'Preview', iconCls: 'silk-accept', margins:'0 0 0 15', handler: function(){ if(uploadexcelform.getForm().isValid()){ ds_mahasiswa.clearData(); Ext.getCmp('btn_export_to_feeder').disable(); uploadexcelform.getForm().submit({ url: BASE_URL + 'feeder/updatemahasiswa_controller/upload_excel', waitMsg: 'Mengupload data ', success: function(form,action){ //add data to grid obj = Ext.util.JSON.decode(action.response.responseText); if(obj.success){ var dt_mahasiswa = obj.data; var mapMahasiswa = new Ext.data.Record.create([ { name: 'no', name: 'nim', name: 'nama', name: 'prodi', name: 'status', name: 'jenis_masuk', name: 'jk', name: 'ttl', name: 'agama', name: 'id_pd', name: 'id_reg_pd', } ]); //loop data mahasiswa for (i = 0; i < dt_mahasiswa.length; i++) { curr_mahasiswa = dt_mahasiswa[i]; ds_mahasiswa.add([ new mapMahasiswa({ 'nim' : curr_mahasiswa.nim, 'nama' : curr_mahasiswa.nama, 'prodi' : curr_mahasiswa.prodi, 'status' : curr_mahasiswa.status, 'jenis_masuk' : curr_mahasiswa.jenis_masuk, 'jk' : curr_mahasiswa.jk, 'ttl' : curr_mahasiswa.ttl, 'agama' : curr_mahasiswa.agama, 'id_pd' : curr_mahasiswa.id_pd, 'id_reg_pd' : curr_mahasiswa.id_reg_pd, }) ]); } check = ds_mahasiswa.getCount(); if(check > 0){ Ext.getCmp('btn_export_to_feeder').enable(); }else{ Ext.getCmp('btn_export_to_feeder').disable(); } }else{ if(obj.message){ Ext.MessageBox.alert('Informasi',obj.message); }else{ Ext.MessageBox.alert('Informasi','Data gagal di export'); } } } }); } } },{ xtype: 'button', id: 'btn_export_to_feeder', margins:'0 0 0 15', iconCls: 'silk-save', text: ' Export To Feeder', disabled: true, handler: function() { export_to_feeder(); } }] }], }); /** FUNCTION for GRID COLUMN EDITOR */ /** GRID COLUMN MODEL */ var cm_mahasiswa = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer({width: 30}), //for rows numbering { header: headerGerid('NIM'), width: 100, dataIndex: 'nim', sortable: true, hidden: true, },{ header: headerGerid('Nama Mahasiswa'), width: 220, dataIndex: 'nama', sortable: true, },{ header: headerGerid('Program Studi'), width: 180, dataIndex: 'prodi', sortable: true, },{ header: headerGerid('Status Mahasiswa'), width: 120, dataIndex: 'status', sortable: true, renderer: fnGenerateStatusMahasiswa, },{ header: headerGerid('Jenis Pendaftaran'), width: 120, dataIndex: 'jenis_masuk', sortable: true, renderer: fnGenerateJPendaftar, },{ header: headerGerid('L/P'), width: 60, dataIndex: 'jk', sortable: true, },{ header: headerGerid('Tempat,Tanggal Lahir'), width: 170, dataIndex: 'ttl', sortable: true, },{ header: headerGerid('Agama'), width: 100, dataIndex: 'agama', sortable: true, }] ); var grid_mahasiswa = new Ext.grid.EditorGridPanel({ id: 'grid_mahasiswa', store: ds_mahasiswa, autoSizeColumns: true, enableColumnResize: true, view: new Ext.grid.GridView({emptyText: '< Belum ada Data >'}), cm: cm_mahasiswa, frame: true, loadMask: true, height: 400, layout: 'anchor', style: 'padding-bottom:5px', }); var fp_mahasiswa = RH.GPContainer1_wHeaders({ title: 'Update Status Mahasiswa', iconCls:'silk-book', gridPanel: grid_mahasiswa, headerLabelWidth: 60, headers: [{ xtype: 'container', layout: 'hbox', items:[{ layout:'form', labelWidth:60, labelAlign:'right', items: [uploadexcelform] }] }], }); SET_PAGE_CONTENT(fp_mahasiswa); function export_to_feeder(){ var waitmsg = Ext.MessageBox.wait('Mengirim data ke aplikasi Feeder...', 'Info'); var dt_mahasiswa = []; for(var zx = 0; zx < ds_mahasiswa.data.items.length; zx++){ var record = ds_mahasiswa.data.items[zx].data; dt_mahasiswa[zx] = record; } Ext.Ajax.request({ url: BASE_URL + 'feeder/updatemahasiswa_controller/export_to_feeder', params: { json_mahasiswa : Ext.encode(dt_mahasiswa) }, success: function(response){ waitmsg.hide(); obj = Ext.util.JSON.decode(response.responseText); if(obj.success === true){ Ext.MessageBox.alert('Informasi','Berhasil mengekspor data mahasiswa ke aplikasi feeder.'); //ds_mahasiswa.clearData(); Ext.getCmp('btn_export_to_feeder').disable(); }else{ Ext.MessageBox.alert('Informasi',obj.message); } } }); } } function headerGerid(text, align){ var hAlign = 'center'; if(align =='c') hAlign = 'center'; if(align =='l') hAlign = 'left'; if(align =='r') hAlign = 'right'; return "