Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jqgrid, call URL with parameters for Json return

Tags:

jqgrid

i have the following code on my aspx page:

jQuery("#listFondos").jqGrid({
    url: '/PorMyController/LoadGridData/',
    datatype: 'json',
    mtype: 'GET',
    colNames: ['col1', 'col2',...etc

Everything is working fine, but i'm wondering if is it possible to call the URL method sending some parameters. I know that by default, when you call the url method, jqgrid sends some parameters to control paging of the grid:

public ActionResult LoadGridData(string sidx, string sord, int page, int rows)

So, i want to add an extra parameter to make some filter on the data that is going to be loaded into the grid. For example i would like to have this:

public ActionResult LoadGridData(string sidx, string sord, int page, int rows, string filterId)

As i know, i don't need to specify the first 3 parameters, cause jqgrid does it by default, but how do i send the filterId parameter?

like image 548
lidermin Avatar asked Dec 07 '09 11:12

lidermin


2 Answers

I solve the problem myself. All that is needed to do is send the parameter as querystring on the url:

url: '/PorMyController/LoadGridData?filterId=123',...etc

The defaul parameters for paging will keep being sended, so you only have to specify the additional parameters.

like image 200
lidermin Avatar answered Nov 02 '22 10:11

lidermin


You can specify a function instead of a named datatype for the datatype parameter. Then in that function you can manually do a jQuery .ajax call with whatever parameters you want. This thread has a good example: here. (Specifically the last answer).

like image 1
maxpower47 Avatar answered Nov 02 '22 08:11

maxpower47