0

I m working on MVC 3 with JQGrid. I have created a Custom Search Panel for the search instead of using the 'filterGrid' or 'filterToolbar'. I have a Users Action from which the JQGrid get filled. i created another Json Action which get the filtered result based on the parameter passed by 'Custom Search Panel'. The Json Action fired by Post method using jquery.

i want to know how to fill the JQGrid with the filtered data ? any ideas?

Saad
  • 1,312
  • 5
  • 17
  • 40

1 Answers1

1

I would suggest you to reload your grid with the standard method myGrid.trigger('reloadGrid'); and let it fetch the parameters needed by your action.
I would use just one action which receives all your filters:

public ActionResult Fetch(string param1, string param2, int param3, int page, int rows, string search, string sidx, string sord)
    {

    }

All you have to do is to define your filter in your jqGrid:

postData: {
            Param1: function() { return $("#param1").val(); },
            Param2: function() { return $("#param2").val(); }
            Param3: function() { return $("#param3").val(); }
        },

wrapping it in function. Now, all you have to do is myGrid.trigger('reloadGrid'); and your jqGrid will fetch the data using your newly define filters. You can read more about it here and here.
As always, Oleg has been great help in that.

Community
  • 1
  • 1
LeftyX
  • 35,328
  • 21
  • 132
  • 193
  • i have tried this , it seems i m near to the solution but i m getting my filter values equal null when i m clicking search button .. any ideas why ? – Saad Jul 30 '11 at 05:07
  • i got 4 searching fields, so i have to create the combination of the fields, using IF statements in my repository class, which get so messy. any solution for this ? – Saad Jul 30 '11 at 07:19
  • 1
    @Saad:You can use different solutions.I guess your repository exposes IQueryable?! Personally I use nHibernate and combine Criterias. There's a good explanation here: http://stackoverflow.com/questions/2500972/linq-to-sql-how-to-efficiently-do-either-an-and-or-an-or-search-for-multiple-cr – LeftyX Jul 30 '11 at 08:52