我正在使用 ExtJS 在选项卡面板中创建一个网格,该网格在每个单元格中都有链接。如果有多个链接,则该行应展开,以便行在需要时变宽。
我正在处理4.1.1
示例 ( var-height-row.js
) 中的“具有可变高度行的缓冲滚动”示例。我似乎无法让它与我的数据一起使用。网格正在显示,但没有任何行可见。如果有人能告诉我我做错了什么,将不胜感激!
我收到的错误消息records
是undefined
并且在我的代码末尾附近被调用。
代码片段
var detailStore;
var detailGrid;
var MON = 'Monday';
var TUE = 'Tuesday';
var WED = 'Wednesday';
var THU = 'Thursday';
var FRI = 'Friday';
var SHIFT = 'shift';
Ext.define('Location', {
extend: 'Ext.data.Model',
fields: [{
name: SHIFT
}, {
name: MON
}, {
name: TUE
}, {
name: WED
}, {
name: THU
}, {
name: FRI
},
'rowHeight'
]
});
function LoadDetailsGrid() {
// create the Data Store
detailStore = Ext.create('Ext.data.Store', {
id: 'detailStore',
pageSize: 50000,
// allow the grid to interact with the paging scroller by buffering
buffered: true,
// never purge any data, we prefetch all up front
purgePageCount: 0,
model: 'Location',
proxy: {
type: 'memory'
}
});
detailGrid = Ext.create('Ext.grid.Panel', {
width: 700,
height: 500,
title: 'Weekly Detail',
store: detailStore,
verticalScroller: {
variableRowHeight: true
},
loadMask: true,
selModel: {
pruneRemoved: false,
selectionMode: 'MULTI'
},
viewConfig: {
trackOver: false
},
// grid columns
columns: [{
flex: 1,
sortable: true,
width: 300,
dataIndex: SHIFT
}, {
text: MON,
width: 125,
sortable: false,
dataIndex: MON
}, {
text: TUE,
width: 125,
sortable: false,
dataIndex: TUE
}, {
text: WED,
width: 125,
sortable: false,
dataIndex: WED
}, {
text: THU,
width: 125,
sortable: false,
dataIndex: THU
}, {
text: FRI,
width: 125,
sortable: false,
dataIndex: FRI
}],
renderTo: detailGridDiv
});
var data = createData(),
ln = data.length,
records = [],
i = 0;
for (; i < ln; i++) {
records.push(Ext.create('Location', data[i]));
}
}
Ext.onReady(function() {
LoadDetailsGrid();
var tabControl = new Ext.TabPanel({
renderTo: 'tabs',
activeItem: 0,
width: 600,
height: 250,
plain: true,
defaults: {
autoScroll: true,
bodyPadding: 10
},
items: [
detailGrid
] // THIS IS WHERE THE ERROR HITS
});
detailStore.cachePage(records, 1);
detailStore.guaranteeRange(0, 5);
});