我有一个网格,我用其他商店的数据手动填写数据:
fillfunction:function(){
var Store=Ext.ComponentQuery.query('#grid')[0].getStore();
var Store2=Ext.ComponentQuery.query('#grid2')[0].getStore();
Store.each(function(record){
var record=Ext.create('App.model.record');
record.data['Referencia_proveedor']=record.data['codigo_erp_producto'];
record.data['Especialidad']=record.data['nombre_comercial_1'];
record.data['Presentacion']=record.data['forma_presentacion'];
record.data['Porc_real_decreto']=record.data['porcentaje_real_decreto'];
record.data['ADJ']=false;
Store2.add(record);
});
}
这个网格有 selType:'checkboxmodel',而且我有一个按钮可以将数据['ADJ']从商店(在这个列类型为boolean的模型中)从false更改为true。 我用下一个代码编辑数据:
changeValue:function(){
var selection=Ext.ComponentQuery.query('#grid2')[0].getSelectionModel().getSelection();
for (i = 0; i < selection.length; i++){
var index=Ext.ComponentQuery.query('#grid2')[0].getStore().indexOf(selection[i]);
var record=Ext.ComponentQuery.query('#grid2')[0].getStore().getAt(index);
record.set('ADJ',true);
}
var total=Ext.ComponentQuery.query('#grid2')[0].getStore().count();
var alterstore=Ext.ComponentQuery.query('#grid2')[0].getStore().getRange(0,total);
Ext.ComponentQuery.query('#grid2')[0].getStore().loadRecords(alterstore,{addRecords: false});
}
如果我再次打印,ADJ的存储de值会更新,但在网格中仍然是旧值。如何更新网格以查看新值?
修改
我的网格代码
var panel1=new Ext.grid.Panel({
itemId:'panel1',
flex:3,
store: store,
title:'<span style="color:blue">Title 1</span>',
scroll:'vertical',
stripeRows: true,
selModel: {
selType: 'checkboxmodel'
},
bbar:{
xtype: 'container',
layout: 'anchor',
items: [bottombar0]
},
loadMask: true,
columns:{
items:[
{header:'<span>R</span>',dataIndex:'Referencia_proveedor',itemId:'',flex:1},
{header:'<span>A</span>',dataIndex:'Especialidad',itemId:'',flex:3},
{header:'<span>P</span>',dataIndex:'Presentacion',itemId:'',flex:1},
{header:'<span>U</span>',dataIndex:'',align:'right',itemId:'',flex:1,renderer:Unidades},
{header:'<span>PVL</span>',dataIndex:'',align:'right',itemId:'',flex:2,renderer:Moneda},
{header:'<span>RD</span>',dataIndex:'Porc_real_decreto',align:'right',itemId:'',flex:1,renderer:Porcentaje},
{header:'<span>ADJ</span>',dataIndex:'',align:'center',itemId:'',flex:1,renderer:adjudicado}
]
}
});
答案 0 :(得分:0)
这很容易,我有一个拼写错误
I32
这里我忘了将dataIndex设置为:
{header:'<span>ADJ</span>',dataIndex:'',align:'center',itemId:'',flex:1,renderer:adjudicado}
忘记设置字段的dataIndex dataIndex:&#39; ADJ&#39;
在控制器中我会做下一步:
{header:'<span>ADJ</span>',dataIndex:'ADJ',align:'center',itemId:'',flex:1,renderer:adjudicado}
用网格刷新的值。我做commitChanges来清除脏字段。