本文介绍了ExtJS网格面板没有从商店填充数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人看到这段代码有什么问题吗?我以ExtJS为例,正在显示网格面板,但数据未被填充。
var arrayData = [
['Jay Garcia','MD'],
['Aaron Baker','VA'],
['Susan Smith' '],
['Mary Stein','DE'],
['Bryan Shanley','NJ'],
['Nyri Selgado','CA']
];
var nameRecord = Ext.data.Record.create([
{name:'name',mapping:1},
{name:'state'映射:2}
]);
var arrayReader = new Ext.data.ArrayReader({},nameRecord);
var memoryProxy = new Ext.data .MemoryProxy(arrayData);
var store = new Ext.data.Store({
reader:arrayReader,
proxy:memoryProxy
});
var colModel = new Ext.grid.ColumnM odel([
{
header:'Full Name',
sortable:true,
dataIndex:'name'
},
{
header:'State',
dataIndex:'state'
}
]);
var gridView = new Ext.grid.GridView();
var selModel = new Ext.grid.RowSelectionModel({
singleSelect:true
});
var grid = new Ext.grid.GridPanel({
title:'My First Grid',
renderTo:Ext.getBody(),
autoHeight:true ,
width:250,
store:store,
view:gridView,
colModel:colModel,
selModel:selModel
});
});
解决方案
我找到了解决方案。
$ b
作者忘记在数据存储中包含autoLoad:true。
Does anyone see what's wrong with this code? I'm following an example from ExtJS in action. The grid panel is being displayed but the data is not being populated.
Ext.onReady(function() {
var arrayData = [
['Jay Garcia', 'MD'],
['Aaron Baker', 'VA'],
['Susan Smith', 'DC'],
['Mary Stein', 'DE'],
['Bryan Shanley', 'NJ'],
['Nyri Selgado', 'CA']
];
var nameRecord = Ext.data.Record.create([
{ name : 'name', mapping : 1 },
{ name : 'state', mapping : 2 }
]);
var arrayReader = new Ext.data.ArrayReader({}, nameRecord);
var memoryProxy = new Ext.data.MemoryProxy(arrayData);
var store = new Ext.data.Store({
reader : arrayReader,
proxy : memoryProxy
});
var colModel = new Ext.grid.ColumnModel([
{
header : 'Full Name',
sortable : true,
dataIndex : 'name'
},
{
header : 'State',
dataIndex : 'state'
}
]);
var gridView = new Ext.grid.GridView();
var selModel = new Ext.grid.RowSelectionModel({
singleSelect : true
});
var grid = new Ext.grid.GridPanel({
title : 'My First Grid',
renderTo : Ext.getBody(),
autoHeight : true,
width : 250,
store : store,
view : gridView,
colModel : colModel,
selModel : selModel
});
});
解决方案
I found the solution.
The author forgot to include autoLoad : true in the data store.
这篇关于ExtJS网格面板没有从商店填充数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!