通过 slickgrid 中的 seacrh 字段将滚动条移动到特定行

move scrollbar to a specific row by seacrh fields in slickgrid

我的 slickgrid 中有一个过滤器,效果很好。我不想过滤,而是想在我输入搜索字段时将光滑网格的滚动条移动到特定行,如果它与我列表中的任何内容匹配。

SlickGrid API 有一个名为 scrollRowIntoView(row, doPaging) 的 public 方法。

参数在哪里:

row - A row index.

doPaging - A boolean. If false, the grid will scroll so the indicated row is at the top of the view. If true, the grid will scroll so the indicated row is at the bottom of the view. Defaults to false.

所以通过发出:

grid.scrollRowIntoView(200, true);

将给定的行号滚动到网格的视口中。

工作代码,以防您正在寻找相同的东西。

function filter(item) {
if (item.LastName == columnFilters.LastName) {
    grid.scrollRowIntoView(item.id, true);
}
return true;
}

dataView.setFilter(filter);