在剔除中,更改数据时更改分页

编程入门 行业动态 更新时间:2024-10-23 07:35:03
本文介绍了在剔除中,更改数据时更改分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在淘汰赛中,我希望更改/刷新数据更改时的分页. 例如:我的数据集为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.

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

Here is my [Fiddle] (jsfiddle/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.

  • all observableArray需要使用新的items值进行更新,因为它在第65行以类似的方式获取值.
  • 需要将
  • pageNumber重置为0,因为paginated和all正在通过计算函数进行监听. (并且该表显示的是paginated的值.)
  • 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.
  • 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).
  • 它看起来像这样更新了小提琴.

    更多推荐

    在剔除中,更改数据时更改分页

    本文发布于:2023-10-16 00:27:26,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1495933.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:分页   数据

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!