简体   繁体   English

重新运行服务器端查询以进行分页,排序或过滤

[英]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? 有什么方法可以在客户端和服务器上使用传统的模型方法执行此操作,还是必须执行FAQ中提到的类似RPC的方法?

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. 并绑定到视图中的filteredItems。 something like this. 这样的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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