简体   繁体   中英

Server side query rerun for paging, sort or filtering

What is the best approach to rerun a server query/subscription for a specific connected client when some data on that client changes?

This would be very useful for server side filtering, ordering or paging.

For example, the client has a table with thousands of lines that are paginated, when the user changes the filtering text or page number the server would recompute the query subscription with that filter, and update the client on the fly.

The search input doesn't have to be synced across all connected users of the server, and thus its not needed to be present in the database.

Is there any way to perform this with traditional model methods on both client and server or do I have to implement a RPC like approach as mentioned in the FAQ?

Thanks!

var filter = model.root.filter('items', 'temp.pageNumber', function(item, x,y,pageNumber){
   if (item.index > pageNumber*10 && item.index < pageNumber*10+10){
      return true;
   }
   return false;
}
model.root.subscribe(filter,function(){
   model.ref('filteredItems', filter);
});

and bind to filteredItems in view. something like this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM