How to force jqgrid to query data using OData in q

2019-08-12 05:40发布

Free jqgrid reads remote json data using

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

search window is defined using

$.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

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.

1条回答
做个烂人
2楼-- · 2019-08-12 06:07

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

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.

查看更多
登录 后发表回答