viewConfig : {
forceFit : true,
deferEmptyText : true,
emptyText : "无相关数据",
// 自定义的滚动方法
// 滚动Grid到指定的Record
scrollToRecord : function(record) {
var index = this.grid.getStore().indexOf(record);
this.scrollToRow(index);
},
// 滚动Grid到指定的列
scrollToRow : function(rowIndex) {
var firstRow = Ext.get(this.getRow(0));
var row = Ext.get(this.getRow(rowIndex));
var distance = row.getOffsetsTo(firstRow)[1];
this.scroller.dom.scrollTop = distance;
}
}
以上配置加在gridpanel中
并通过获取表格的store,使用find方法找到对应数据所在的索引
let index = Ext.getCmp("").getStore().find("",value);
if (index != -1){
Ext.getCmp("").getSelectionModel().selectRow(index);
Ext.getCmp("").getView().scrollToRow(index);
}