RIA 服务 JSON 和 Ext.Js
我们将 Sencha Ext JS 4 用于我们的 LOB 应用程序。在服务器上,我们使用带有 JSON 端点的 MS RIA 服务(Data Domain 服务)。一般来说,一切正常。但分页却不然。 首先,我们发现 JSON 请求 URL 包含 RIA 简单忽略的关键字(状态、页面等)。经过一番研究,我发现我可以使用以下语法:
例如:
http://localhost/Product/ServiceName.svc/JSON/GetItems?_dc=1328305056811&$take=50&$skip=50
即 $skip(如果您使用 $skip - 您有对 RIA 端的查询进行排序)和 $take,这样的请求会返回适当数量的记录。然而 JSON 响应一开始看起来像这样:
{"GetItemsResult":{"TotalCount":-1,"RootResults":[
即 TotalCount = -1 - 为了使分页正常工作,JS 需要知道记录总数,这是我可以看到它工作的唯一方法 - 如果我使用单独的请求查询记录数并且然后进行页面查询。
问题是我错过了什么吗? RIA 服务有可能返回正确的 TotalCount(如果没有 $skip 或 $take - RIA 服务发回整个表并正确指定 TotalCount)。
We using Sencha Ext JS 4 for our LOB Application. On the server we use MS RIA services ( Data Domain Services ) with JSON endpoint. In general everything working ok.But paging is not.
first of all we discovered that JSON request URL had keywords that RIA simply ignored ( state, page etc. ) after some research I found out that I can use following syntax :
For Example:
http://localhost/Product/ServiceName.svc/JSON/GetItems?_dc=1328305056811&$take=50&$skip=50
i.e. $skip ( if you use $skip - you have to sort query on RIA side ) and $take, request like that return appropriate number of records. However
JSON response looks like this at the beginning:
{"GetItemsResult":{"TotalCount":-1,"RootResults":[
i.e. TotalCount = -1 - in order for paging to work properly JS needs to know total number of records and the only way I can see this working - if I query number of records with separate request and then do page query.
Question is do I miss something ? It is possible for RIA Service to return correct TotalCount ( if there is not $skip or $take - RIA Service send back entire table and specify TotalCount correctly ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,我不太了解您在服务器端使用的技术。我正在使用 Grails,对此我感到非常高兴。所以我对你的总数无法提供太多帮助。
然而,对于分页参数,ExtJS 允许将其期望发送/接收的内容转换为服务器端期望的内容。像这样:
另一个想法:如果您无法使服务器端发送总计数,请在存储上创建一个侦听器并在加载时手动计算记录并将其设置到存储的totalCOunt属性中。
祝你好运。
德米特里.
I am sorry I don't know much about the technology you are using on the server side. I am using Grails and cannot be happier. So I cant help you much with your total count.
However for the paging paramters ExtJS allows for translation of what it expects to send/receive to what your server side expects. Like this:
On another thought: if you cant make your server side send total count, create a listener on the store and count the records manually on load and set it into the totalCOunt property of the store.
Good luck.
Dmitry.
查看 inlinecount 选项:
http://msdn。 microsoft.com/en-us/library/dd942040(v=prot.10).aspx
Look at the inlinecount option:
http://msdn.microsoft.com/en-us/library/dd942040(v=prot.10).aspx