如何在查询字符串中使用OData强制jqgrid查询数据 [英] How to force jqgrid to query data using OData in query string

查看:50
本文介绍了如何在查询字符串中使用OData强制jqgrid查询数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免费的jqgrid使用读取远程json数据

Free jqgrid reads remote json data using

  $.jgrid.useJSON = true;
  $.extend(true, $.jgrid.defaults, {
            mtype: 'GET',
            url: '@Html.Raw(Url.Action("Entity", "API",))'
    } );

搜索窗口是使用

$.extend(true, $.jgrid.search, {
            multipleSearch: true,
            recreateFilter: true,
            closeAfterSearch: true,
            overlay: 0,
            recreateForm: true
        });

如果按下搜索按钮,则会像创建丑陋的过滤器查询字符串参数一样

If search button is pressed, ugly filters query string parameter is created like

http://localhost:52216/admin/API/Entity/DoklstlG?search=true&nd=1448746804617&rows=20&page=1&sidx=customer&_sord=desc&filters=%7B%22groupOp%22%3A%22AND%22%2C%22rules%22%3A%5B%7B%22field%22%3A%22Klient_nimi%22%2C%22op%22%3A%22cn%22%2C%22data%22%3A%22a%22%7D%5D%7D

如何更改此url,尤其是以OData格式生成的filter子句? 我阅读了jqgrid OData插件Wiki文章,但还没有发现这种可能性.

How to change that this url, especially filters clause in generated in OData format ? I read jqgrid OData plugin wiki article but havent found such possibility.

推荐答案

我不建议您使用现成的解决方案,但我指出了实现要求的方向.

I can't suggest you an ready to use solution, but I point you in the direction how you can implement the requirement.

首先,我建议您阅读答案?它显示了如何使用服务器端的OData排序和分页.需要使用$top$skip$orderby$inlinecount URI参数,这些参数可以在serializeGridData中设置.一个人可以用相同的方式实现过滤.需要将jqGrid创建的filters参数转换为对象并解析所有规则.一个需要生成相应的$filter参数,该参数支持OData(例如此处此处).重要的是要了解,通用实现不是那么容易,它可能取决于您使用的OData实现的确切版本.

First of all I would recommend you to read the answer? It shows how to use server side sorting and paging of OData. One need to use $top, $skip, $orderby and $inlinecount URI parameters which can be set inside of serializeGridData. One can implement filtering in the same way. One need to convert filters parameter, created by jqGrid, to the object and parse all the rules. One need generate the corresponding $filter parameter, which support OData (like here and here). It's important to understand that the common implementation is not so easy and it could depend on the exact version of OData implementation which you use.

这篇关于如何在查询字符串中使用OData强制jqgrid查询数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆