Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Grid PostData is not passing values to the controller action method - MVC3
    text
    copied!<p>I am using JQuery grid for displaying some data on the page. I have got a list of checkboxes for applying filter to the grid which I need to pass to the controller action method. My problem is eventhough the value of the selected checkboxes are correctly retrieved before passing it the post data , it is not showing up in the controller. Intersetingly, if I am loading the page with the checkboxes selected, in that case the value is getting passed. I am very confused why this is happening. I'll be really greatful for any help. Please see the code below which I am using for binding the grid:</p> <pre><code> function BindGrid() { var selectedPriority = []; $('#priority input:checked').each(function () { selectedPriority.push($(this).val()); }); var selectedState = []; $('#state input:checked').each(function () { selectedState.push($(this).val()); }); var selectedAckState = []; $('#ackState input:checked').each(function () { selectedAckState.push($(this).val()); }); var x = convertIntArrayToString(selectedPriority); var y = convertIntArrayToString(selectedState); var z = convertIntArrayToString(selectedAckState); jqDataUrl = "Alarm/LoadjqData"; // Set up the jquery grid //$("#jqTable").jqGrid('clearGridData'); $("#jqTable").jqGrid({ url: jqDataUrl, datatype: "json", mtype: "POST", postData: { sp: x, ss: y, sak: z }, cache: false, // Specify the column names colNames: ["Id", "PointRef", "Value", "AlarmStateName", "AckStateName", "Priority", "AlarmDate"], // Configure the columns colModel: [ { name: "AlarmId", index: "AlarmId", width: 70, align: "left" }, { name: "PointRef", index: "PointRef", width: 200, align: "left" }, { name: "Value", index: "Value", width: 200, align: "left" }, { name: "AlarmStateName", index: "AlarmStateName", width: 150, align: "left" }, { name: "AcknowledgementStateName", index: "AcknowledgementStateName", width: 170, align: "left" }, { name: "Priority", index: "Priority", width: 100, align: "left" }, { name: "AlarmDate", index: "AlarmDate", width: 250, align: "left" } ], // Grid total width and height width: 700, height: 250, // Paging toppager: true, pager: $("#jqTablePager"), rowNum: 10, rowList: [5, 10, 20], viewrecords: true, // Specify if "total number of records" is displayed // Default sorting sortname: "AlarmId", sortorder: "desc", // Grid caption caption: "Telemetry Alarms" }).navGrid("#jqTablePager", { refresh: true, add: false, edit: false, del: false }, {}, // settings for edit {}, // settings for add {}, // settings for delete {sopt: ["cn"]} // Search options. Some options can be set on column level ) //.trigger('reloadGrid', [{ page: 1}]); .trigger('reloadGrid'); } function convertIntArrayToString(data) { var x=''; //alert(data.length); for(var i=0;i&lt;data.length;i++) { x = x + data[i] + ","; } if (x != '') { x = x.substr(0, x.length - 1); //alert(x); } return x.toString(); } //Controller action method [HttpPost] public ActionResult LoadjqData(string sidx, string sord, int page, int rows, bool _search, string searchField, string searchOper, string searchString, string sp, string ss, string sak) { //code ommited. return Json(jsonData); } </code></pre> <p>value of sp, ss and sak parameters are not apprearing in the controller.</p>
 

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