ExtJs4 获取grid.panel中的被修改数据
var updateBtn=Ext.create('Ext.Button', {
text: '保存修改',
ionCls:"icon-edit",
handler: function(){
var _grid = Ext.getCmp("id_of_grid");
//我尝试了很多方法都获取不到
var m = _grid.getStore().getUpdatedRecords();
if(m.length == 0) {
Ext.MessageBox.alert("信息","没有任何记录被修改");
return;
}
var jsonArray = [];
Ext.each(m,function(item){
jsonArray.push(item.data);
alert(item.data);
});
Ext.Ajax.request({
method:'POST',
url:'user_update.action',
success:function(response) {
Ext.MessageBox.alert("信息",response.responseText,function(){
store.load();
store.modified = [];
});
},
failure:function(){
Ext.MessageBox.alert("错误","与后台联系的时候出了问题");
}
,
params:'data=' + Ext.encode(jsonArray)
});
}
});
var grid = Ext.create('Ext.grid.Panel', {
title:'Progress Bar Pager',
id:'id_of_grid',
selModel: selModel,
renderTo:Ext.getBody(),
region:'center',
layout:'fit',
border:false,
store: store,
columns: [{
text: '编号',
sortable: true,
hidden:true,
dataIndex: 'id',
flex: 1
},{
text: '账号',
sortable: true,
// renderer: Ext.util.Format.usMoney,
dataIndex: 'userAccount',
flex: 1,
editor: {
xtype: 'textfield'
}
},{
text: '真实姓名',
sortable: true,
renderer: change,
dataIndex: 'realName',
flex: 1
,
editor: {
xtype: 'textfield'
}
},{
text: '职务',
sortable: true,
renderer: pctChange,
dataIndex: 'userDuty',
flex: 1 ,
editor: {
xtype: 'textfield'
}
},{
text: '性别',
sortable: true,
renderer: pctChange,
dataIndex: 'sex',
flex: 1,
editor:{
xtype: 'combobox',
id:'sex',
typeAhead: true,
triggerAction: 'all',
queryMode: 'local',
store: sexstore,
selectOnTab: true,
lazyRender: true,
displayField:'name',
valueField:'id',
listClass: 'x-combo-list-small',
listeners:{
select : function(combo, record,index){
isEdit = true;
}
}
},renderer:rendererData
},
{