使用以下代码片段,网格仅显示列标题。要显示数据,我需要添加最后一行。为什么数据显示在网格中需要renderArray?
var data = [
{ first: 'Bob', last: 'Barker', age: 89 },
{ first: 'Vanna', last: 'White', age: 55 },
{ first: 'Pat', last: 'Sajak', age: 65 }
];
var store = new Memory({ data: data });
var grid = new OnDemandGrid({
collection: store,
columns: {
first: 'First Name',
last: 'Last Name',
age: 'Age'
}
});
grid.startup();
//grid.renderArray(data);
答案 0 :(得分:0)
您使用的是哪个版本的API?我只是将您的代码复制/粘贴到引用4.1 API的JSFiddle中,它似乎工作正常:
https://jsfiddle.net/shenningsgard/udxkuqr1/3/
HTML:
<div id="myGrid"></div>
JS:
require(['dgrid/OnDemandGrid', 'dstore/Memory'], function(OnDemandGrid, Memory) {
var data = [{
first: 'Bob',
last: 'Barker',
age: 89
}, {
first: 'Vanna',
last: 'White',
age: 55
}, {
first: 'Pat',
last: 'Sajak',
age: 65
}];
var store = new Memory({
data: data
});
var grid = new OnDemandGrid({
collection: store,
columns: {
first: 'First Name',
last: 'Last Name',
age: 'Age'
}
}, 'myGrid');
grid.startup();
});
结果:
First Name Last Name Age
Bob Barker 89
Vanna White 55
Pat Sajak 65
答案 1 :(得分:0)
回答我的问题:引用dgrid1目录而不是dgrid。