日期:2014-05-16 浏览次数:20736 次
Ext.onReady(function(){ var cm = new Ext.grid.ColumnModel([ {header:'客户',dataIndex:'customsNo',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))}, {header:'订单号',dataIndex:'soNo',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))}, {header:'订单日期',dataIndex:'date',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))}, {header:'订单类型',dataIndex:'type',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))}, {header:'ETA',dataIndex:'eta',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))}, {header:'部门',dataIndex:'department',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))}, {header:'参考号',dataIndex:'ref',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))}, {header:'状态',dataIndex:'status',editor:new Ext.grid.GridEditor(new Ext.form.TextField({ allowBlank: false }))} ]); var store = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({url:"test.jsp"}), reader: new Ext.data.JsonReader({ totalProperty:'totalCount', root:'result' }, [ {name: 'customsNo',type: 'String'}, {name: 'soNo',type: 'String'}, {name: 'date',type: 'String'}, {name: 'type',type: 'String'}, {name: 'eta',type: 'String'}, {name: 'department',type: 'String'}, {name: 'ref',type: 'String'}, {name: 'status',type: 'int'} ]), remoteSort: true }); store.load(); var grid = new Ext.grid.EditorGridPanel({ autoHeight: true, renderTo: 'grid', store: store, loadMask: true, cm: cm, tbar: new Ext.Toolbar([ '-', { text: '删除一行', handler: function(){ Ext.Msg.confirm('信息', '确定要删除?', function(btn){ if (btn == 'yes') { var sm = grid.getSelectionModel(); var cell = sm.getSelectedCell(); var record = store.getAt(cell[0]); store.remove(record); } }); } }, '-', { text: '保存', handler: function(){ var m = store.modified.slice(0); var jsonArray = []; Ext.each(m, function(item) { jsonArray.push(item.data); }); Ext.lib.Ajax.request( 'POST', 'extjs/save.action', {success: function(response){ Ext.Msg.alert('信息', response.responseText, function(){ Ext.Msg.alert('message',response.responseText); }); },failure: function(){ Ext.Msg.alert("错误", "与后台联系的时候出现了问题"); }}, 'data=' + encodeURIComponent(Ext.encode(jsonArray)) ); } }, '-']) });