Note that there are some explanatory texts on larger screens.

plurals
  1. POControlling the JqGrid Parameters While Making an Ajax Post in MVC2
    primarykey
    data
    text
    <p>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.</p> <p>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?</p> <p><strong>EDIT</strong></p> <p>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.</p> <p>what i need is this which does not work only the 1st parameter is populated:-</p> <pre><code>public void Jgrid(Jgrid grid,object hdnupdpg,string p_roleid) { } </code></pre> <p>but how do i make Jgrid.ajax call send these otherparams ? with "<strong>paramsData</strong>" option only?</p> <p>here is the server side function prototypes i came across :</p> <pre><code>public void JGridData(JGrid grid) { } </code></pre> <p>And here is the grid class</p> <pre><code> 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) &amp;&amp; !string.IsNullOrEmpty(filter)) return defaultFilter + " AND (" + filter + ")"; else if (!string.IsNullOrEmpty(defaultFilter)) return defaultFilter; return filter; } } public string BuildFilter() { .... } } </code></pre> <p><strong>EDIT</strong></p> <pre><code>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' } ] }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload