jqGrid postData property not loading pre-loaded filter
Asked Answered
S

1

0

I am trying to have the page load with a pre-defined filter already applied to the grid.I've tried the following code without success.

$("table#worksheetsTable").jqGrid("setGridParam", {
            gridComplete: function() {
                //tried to set all this here too
            },
            postData: { searchField: "ScreeningNumber", searchString: "8882", searchOper: "bw" },
            search: true
        });

I've also tried $("table#worksheetsTable").jqGrid("setGridParam", {search: true}) outside of the first call as well. When I compare the form values generated with this and with what occurs when i click on the filter myself with Fiddler, they look the same.

UPDATE: Every example of this I've found has to do with multiple filters... I've finally found this answer from Oleg that explains (i think) that doing a single filter is different than doing multiple filters. I will update this and mark the answer once I try this.

Samford answered 19/3, 2012 at 1:15 Comment(1)
You should post more full code which you use.Rosio
H
1

add trigger('reloadGrid') after changing grid parameters like so:

$("table#worksheetsTable").jqGrid("setGridParam", {
            gridComplete: function() {
                //tried to set all this here too
            },
            postData: { searchField: "ScreeningNumber", searchString: "8882", searchOper: "bw" },
            search: true
        }).trigger('reloadGrid');

editing after the ensuing discussion:

could be an issue of the parameter names you are using according to the documentation of the helper you are using

make sure the request parameter names you have in your mvc action method match whatever you set in your postdata, also the searchoperation enum is supposed to contain 'Bw' not 'bw' - depends on whether the helper uses a case insensitive method to parse the enum.

link to documentation here

Hotel answered 19/3, 2012 at 1:18 Comment(8)
or just use the easier $("table#worksheetsTable").jqGrid({all your parameters here}); instead of using setGridParam; if as I understand it this is the 1st load of the gridHotel
I've tried this as well... and as far as your comment, I would but I'm actually using an MVC helper method to generate all that from Lib.Web.Mvc link and when it generates the initial jqGrid initialization it still doesnt work..Samford
mybe its not a good idea to mix client side manipulation and a 3rd party server side generated grid;maybe the helper uses soem custom handling methods/variables; is there a sever side method for the helper to set grid params or even to reload the grid?Hotel
lets see all your server side handling of the request parameters in your action methodHotel
this is what it generates for the jqgrid init, postData: {"searchField":"ScreeningNumber","searchString":"854","searchOper":"bw","search":true},rowNum: 15 i've had it generate key/value like searchField: "ScreeningNumber" too.. still didn't work. As far as I'm concerned I'm doing the same thing that this is doing... except I need a single filter not multiple filters.Samford
what I mean is how is your mvc app handling the filtering? could your issue be a server side issue?Hotel
@diegohb: Do you use postData: {"searchField": "ScreeningNumber", "searchString": "854", "searchOper": "bw", "search"‌​: true}, rowNum: 15 or postData: {"searchField": "ScreeningNumber", "searchString": "854", "searchOper": "bw"}, "search"‌​: true, rowNum: 15? The search: true should be not the part of postData.Rosio
I've tried including it and excluding it with no luck.. Do I need to extend postData with original postData obj ?Samford

© 2022 - 2024 — McMap. All rights reserved.