【问题标题】:Slickgrid - dataview not updatedSlickgrid - 数据视图未更新
【发布时间】:2017-09-27 11:40:42
【问题描述】:

我正在对光滑网格数据应用过滤器,它会更改页脚中的记录数,但不会刷新表中的数据并始终显示所有记录。

代码:

$('#shade-number').keyup(function(e) {
       // clear on Esc
       if (e.which == 27) {
          this.value = "";
       }

        searchList = $.trim(this.value.toLowerCase()).split(' ');
        dataViewAdd.setFilter(gridFilter);  
        gridPo.invalidate();
        this.focus();
});

function gridFilter(rec) {
    var found;

    for (i = 0; i < searchList.length; i += 1) {
        found = false;
        $.each(rec, function(obj, objValue) {
            if (typeof objValue !== 'undefined' && objValue != null 
            && objValue.toString().toLowerCase().indexOf(searchList[i]) != -1) {
                found = true;
                return false; //this breaks the $.each loop
            }
        });
        if (!found) {
            return false;
        }
    }

    return true;
}

在表尾显示Showing all 4 rows,但在表中显示所有记录。

【问题讨论】:

    标签: javascript filter slickgrid


    【解决方案1】:

    听起来您没有关联 OnRowCountChanged 和 OnRowsChanged 事件。 您应该始终从一个工作示例开始,例如:

    http://6pac.github.io/SlickGrid/examples/example4-model.html

    并根据您的需要对其进行修改。然后,如果出现问题,您可以逐步追溯您的更改,直到它起作用。 此外,能够发布一个完整工作示例的链接更容易调试。我敢打赌,问题出在上面没有提到的代码中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多