我的页面上有一个Gridview,我使用的是缓冲存储。有没有办法获得可见的行数。谢谢
答案 0 :(得分:0)
以下是您可以尝试的示例代码:(我希望您能从中获得一些想法)
// The below condition has to be checked for each record
// record: record instance
var me = this; // grid scope
Ext.Array.each(me.columns, function (item) { // iterate through each column in the grid
if (item.hidden || !item.dataIndex) { // you can avoid hidden columns and one's that re not bound to the store
return;
}
var cellVal;
try {
cellVal = Ext.fly( me.view.getCell(record, item)).select('cell selector class').elements[0].innerHTML;
} catch (e) {
// handle if you want
}
if (!Ext.isEmpty(cellVal)) {
// this record has been rendered
}
}, this);
这将获取所有渲染的记录。由于您使用的是bufferedRenderer,这也会返回渲染但不在视图中的记录,您可以检查并为缓冲区添加偏移量。
注意:我在使用ExtJs 5时有类似的逻辑,但还没有接触过测试。