在剔除中,更改数据时更改分页 [英] In knockout Change Paging when Data is changed

查看:52
本文介绍了在剔除中,更改数据时更改分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在淘汰赛中,我希望更改/刷新数据更改时的分页. 例如:我的数据集为100 [每页5条记录],我在第10页上.现在有了更多搜索,数据从100更改为5,我在第10页上,但是当数据更改后,我要分页在首页上.即要刷新的页面.

In knockout I wish to change/ refresh Paging when data is changed. For example: I have a data set of 100[5 Records per Page] and I am on Page 10. Now with some more search Data is changed from 100 to 5 and I am on Page 10, but when data is changed I want paging to be on First page. i.e Paging to be refreshed.

这是我的[小提琴]( https://jsfiddle.net/975ncawv/281/)

Here is my [Fiddle] (https://jsfiddle.net/975ncawv/281/)

MyVM.prototype.loadData = function(rawData) {
  this.items(rawData.map(RowModel.fromRawDataPoint));
};
ko.applyBindings(new MyVM(myData));

推荐答案

loadData函数中需要更改两件事.

Two things need to be changed inside the loadData function.

  1. all observableArray需要使用新的items值进行更新,因为它在第65行以类似的方式获取值.
  2. 需要将
  3. pageNumber重置为0,因为paginatedall正在通过计算函数进行监听. (并且该表显示的是paginated的值.)
  1. The all observableArray needs to be updated with the new values of items, since it gets the values in a similar fashion in line 65.
  2. pageNumber needs to be reset to 0, since paginated and all are listening to it through the computed function. (And the table is displaying the values of paginated).

它看起来像这样更新了小提琴.

这篇关于在剔除中,更改数据时更改分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆