In knockout Change Paging when Data is changed
Clash Royale CLAN TAG#URR8PPP
In knockout Change Paging when Data is changed
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.
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));
2 Answers
2
Two things need to be changed inside the loadData
function.
loadData
all
items
pageNumber
paginated
all
paginated
It would look like this updated fiddle.
but when data is changed
this.items.subscribe( /* ... */ )
I want paging to be on First page
this.pageNumber(0)
Put together:
this.items.subscribe(function()
this.pageNumber(0);
, this);
I don't see any logic concerning the search data, but I'd expect something along the lines of:
this.filteredItems = ko.pureComputed(function()
return this.items().filter(/* ... */);
, this);
Once implemented, you can change the subscribe to items
to be on filteredItems
to make sure you reset both when the data source changes as well as when the search query changes.
items
filteredItems
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.