I am confused about the guide lines for dealing with ajax post requests in MVC2 How do i know what data the grid is passing as request parameters? in what order and what data type? because after knowing this only one can design the server side post method. I have seen many example with different function prototypes as server side method handler.
How is that possible? i mean it is the same jqgrid which doing ajax post. How can there be different types of function prototypes as server side action for the same jqgrid?
EDIT
My requirement is i want to send some extra data like a dropdown list selected value when ever JqGrid does an ajax call. But MVC does accept only the JqGrid parameters. I have a workaround though i add extra data through "paramData" and i am able to receive it in the controller request handler. The problem is we use a Grid class which deserializes the Grid parameters and this class is global to the app. so modifying it for each page is a no.
what i need is this which does not work only the 1st parameter is populated:-
public void Jgrid(Jgrid grid,object hdnupdpg,string p_roleid)
{
}
but how do i make Jgrid.ajax call send these otherparams ? with "paramsData" option only?
here is the server side function prototypes i came across :
public void JGridData(JGrid grid)
{
}
And here is the grid class
public class JGrid
{
private bool IsSearch;
public string sidx { get; set; }
public string sord { get; set; }
public int page { get; set; }
public int rows { get; set; }
public bool _search
{
get
{
string strSearch = HttpContext.Current.Request["_search"];
if (!string.IsNullOrEmpty(strSearch))
return Convert.ToBoolean(strSearch);
else
return IsSearch;
}
set { IsSearch = value; }
}
public string searchOper { get; set; }
public string filters { get; set; }
public int totalRecords { get; set; }
public string procName { get; set; }
public string SearchValue { get; set; }
public string SearchField { get; set; }
public string defaultFilter { get; set; }
public string SortExpression
{
get { return sidx + " " + sord; }
}
public string FilterExpression
{
get
{
string filter = BuildFilter();
if (!string.IsNullOrEmpty(defaultFilter) && !string.IsNullOrEmpty(filter))
return defaultFilter
+ " AND (" + filter + ")";
else if (!string.IsNullOrEmpty(defaultFilter))
return defaultFilter;
return filter;
}
}
public string BuildFilter()
{
....
}
}
EDIT
Here is my Script for JqGrid
jQuery('#jgrid').jqGrid({
autowidth: true,
altRows: true,
altclass: 'grdAltRwClr',
datatype: 'local',
forceFit: true,
gridview: true,
height: 290,
mtype: 'post',
rowList: [10, 20, 30],
rowNum: 10,
pager: '#pager',
pagerpos: 'right',
recordpos: 'left',
rownumbers: false,
scrollrows: false,
sortname: 'roledtlid',
toolbar: [true, "top"],
url: rootPath + 'RoleDetail/JGridData',
postData: { extraparams: function() { return escape(jQuery('#hdnupdpg').val()); },
parentid: function() { return escape(jQuery('#p_roleid').val()); }
},
beforeSelectRow: function(rowid, e) { return false; },
gridComplete: function() { GridComplete() },
colModel: [
{ name: 'act', label: 'View', resizable: false, search: false, sortable: false, title: false, width: 6, index: 'act' }
, { name: 'roleid', label: 'Role id', width: 10, index: 'roleid' }
, { name: 'rolename', label: 'Role Name', width: 25, index: 'rolename' }
, { name: 'pgname', label: 'Page Name', width: 30, index: 'pgname' }
, { name: 'canedit', label: 'Edit', width: 10, index: 'canedit' }
, { name: 'canview', label: 'View', width: 10, index: 'canview' }
]
});