【问题标题】:KOGrid clicking the next page button does nothingKOGrid 点击下一页按钮什么也不做
【发布时间】:2018-08-30 22:23:46
【问题描述】:

使用 KOGrid 我在 JS 视图模型中有以下内容:

self.gridOptions = {
            data: self.recs,
            columnDefs: self.columnDefs,
            autogenerateColumns: false,
            showGroupPanel: false,
            showFilter: true,
            filterOptions: self.filterOptions,
            enablePaging: true,
            pagingOptions: self.pagingOptions,
            sortInfo: self.sortInfo,
            rowHeight: 35,
            selectWithCheckboxOnly: true,
            selectedItems: self.selected,
            canSelectRows: true,
            displaySelectionCheckbox: true,
            afterSelectionChange: function () {
                var selectedParent = self.selected()[0];
                if (!selectedParent) {
                    return [];
                }
                var selectedTransactions = selectedParent.editableTransactions();
                self.selectedChildren(selectedParent.editableTransactions());
                return true;
            },
            multiSelect: false,
        };

我可以通过直接输入页码来浏览页面。导航返回按钮工作正常,但单击导航下一页或最后一页没有任何作用。

我在同一个网站的不同页面上有另一个 KOGrid 实例,它工作正常。我使用了 Chrome 开发工具,从网络选项卡中,我可以看到在单击上一个导航按钮时正在发出获取请求,但在下一个导航上没有发出请求。

有什么想法吗?

【问题讨论】:

  • self.pagingOptions 长什么样子?
  • 谢谢 Forty3 - 你是对的!

标签: knockout.js kogrid


【解决方案1】:

问题是,在进行 Ajax 调用后,我使用以下内容设置了 totalServerItems:

self.pagingOptions.totalServerItems(data.Vouchers.length);

这是行不通的,因为 data.Vouchers 只包含当前页面的记录。解决方法是更改​​为以下行:

self.pagingOptions.totalServerItems(data.TotalCount);

【讨论】:

  • 很高兴你找到它!
猜你喜欢
  • 2012-10-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-12
  • 2020-05-28
  • 1970-01-01
  • 2018-04-25
  • 2017-03-16
相关资源
最近更新 更多