How to force jqgrid to query data using OData in query string

一曲冷凌霜 提交于 2020-01-06 02:07:48

问题


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:


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.



来源:https://stackoverflow.com/questions/33976870/how-to-force-jqgrid-to-query-data-using-odata-in-query-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!