简体   繁体   English

jqGrid使用Backbone进行分页

[英]jqGrid using Backbone with paging

I see some examples of commercial app for support of MVC (asp.net) with jqGrid and I'm trying to determine the best approach in using the jQgrid with the Backbone.js client side mvc. 我看到一些商业应用程序的示例,用于支持带有jqGrid的MVC(asp.net),我正在尝试确定将jQgrid与Backbone.js客户端mvc一起使用的最佳方法。

We are currently using a Backbone view that holds the jqgrid fine with smaller tables and 'local' datatype that is supplied by the backbone collection. 我们目前正在使用Backbone视图,该视图使用较小的表和由骨干集合提供的“本地”数据类型来保存jqgrid。

In order to support paging & virtualscroll I'd like to have the backbone model/collection support getting the data from the server and any search/filtering options and pass the output onto the view and jqgrid to update the grid with. 为了支持分页和虚拟滚动,我希望骨干模型/集合支持从服务器和任何搜索/过滤选项获取数据,并将输出传递到视图和jqgrid以更新网格。

It seems the jqGrid has some hooks to events like beforeRequest, loadBeforeSend that I could hook into and do a collection call to make the ajax request and return the json and update the collection (making use of Addy's Backbone Paginator collection) but it seems jqgrid would still be doing the ajax call which seems incorrect to have the view in control instead of the model. 似乎jqGrid有一些事件的钩子,比如beforeRequest,loadBeforeSend,我可以挂钩并做一个集合调用来发出ajax请求并返回json并更新集合(利用Addy的Backbone Paginator集合)但似乎jqgrid会仍在进行ajax调用,这似乎是不正确的控制视图而不是模型。

If I use a custom datatype I could trap the condition when the grid needs to fetch more data and have the bb collection supply that function and for the fetch for the data. 如果我使用自定义数据类型,我可以在网格需要获取更多数据并让bb集合提供该函数以及获取数据时陷阱。

Is the custom datatype the best option is there better way to hook in a backbone model/collection to the jqgrid? 自定义数据类型是最好的选择是否有更好的方法将主干模型/集合挂钩到jqgrid?

In a backbone environment, you NEED to have the table tied directly to the collection with appropriate listeners to update data, otherwise you're either relying on a static view -- which is the opposite of the reason you used backbone -- or you're going to spend countless hours hooking callbacks to update a grid that was never meant for anything live. 在骨干环境中,您需要使用适当的侦听器将表直接绑定到集合以更新数据,否则您要么依赖静态视图 - 这与您使用主干的原因相反 - 或者您我将花费无数个小时来挂钩回调来更新一个从未意味着任何直播的网格。

I've done datatables.net twice in a Backbone environment, and both attempts were a mess because I was essentially brute-forcing datatables to update it's own model, which was overkill. 我在Backbone环境中已经完成了两次datatables.net,并且两次尝试都是一团糟,因为我基本上是强制数据包来更新它自己的模型,这是过度的。 Likewise, trying to take advantage of Datatable's server-side options were pretty much out the window, because it conflicted with the Backbone system of Ajax transactions. 同样,尝试利用Datatable的服务器端选项几乎不在窗口,因为它与Ajax事务的Backbone系统冲突。

Take a look at Backgrid , which is built from the ground-up to be used with Backbone. 看看Backgrid ,它是从头开始构建的,用于Backbone。 Far and away, it's the simplest, cleanest, lowest overhead option I've found so far. 这是迄今为止我发现的最简单,最干净,最低开销的选项。

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

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