0

Grid having 3 options 1) My filters - Which are saved by me 2) Shared filters - which are shared by others 3) All - Both my and shared

I want to display grid with result default to my filters. I have loaded all filters at once, By default it must show my filters records, but showing all filters records. On selection of respective options mentioned above, grid loads data properly. Problem is only with default my filters Please help me.

ani
  • 3
  • 2
  • Please write always **the version** of jqGrid, which you use (can use), and **the fork** ([free jqGrid](https://github.com/free-jqgrid/jqGrid), commercial [Guriddo jqGrid JS](http://guriddo.net/?page_id=103334) or an old jqGrid in version <=4.7). Additionally, it's important to know how you fill jqGrid with data and which `datatype` you use. JavaScript code could be very helpful. In case of usage free jqGrid fork you can use `forceClientSorting: true` option in combination with `loadonce: true`. It allows to sort and filter data loaded from the server. – Oleg Apr 25 '19 at 17:56
  • Hi, Thanks for response. I am using jqGrid version 4.6.0. and I am filling jqgrid data with datatype as json. With forceClientSorting:true, the problem is not solved. However I have used postdata.filters as {"groupOp":"OR","rules":['+ '{field: "shared_by", op: "eq", "data": " "}'+ ',{field: "shared_by", op: "eq", "data": "'+login_user_id+'"}]}'}; but the data it shows in grid as all filters records. but I want to show data which satisfies above conditions. – ani Apr 26 '19 at 05:47
  • jqGrid 4.6 is more as **5 years old** and the option `forceClientSorting` is not yet implemented. You have to upgrade to [free jqGrid](https://github.com/free-jqgrid/jqGrid) (4.15.5), which is compatible with old jqGrid 4.6. – Oleg Apr 26 '19 at 05:57

1 Answers1

0

I recommend you to upgrade old jqGrid 4.6 to the current version of free jqGrid. See here more details about the usage of free jqGrid. After the upgrade you can use the following options

datatype: "json",
loadonce: true,
forceClientSorting: true // force local sorting and filtering
search: true, // to apply the filter from postData.filters
postData: {
    // the filters property is the filter, which need be applied
    // to the data loaded from the server
    filters: JSON.stringify({
        groupOp: "OR",
        rules: [
            { field: "shared_by", op: "eq", data: " " },
            { field: "shared_by", op: "eq", data: login_user_id }
        ]
    })
},
...

the exact value of the postData.filters depends on the data saved on the server. As an example of usage see the demo https://jsfiddle.net/OlegKi/epcz4ptq/, created for the old answer. See another old answer for additional information.

Oleg
  • 220,925
  • 34
  • 403
  • 798