in my asp.net mvc, using jqGrid to bind the data. code is as below. But its not loading the data and not hitting the controller action when debugging. what's the problem in this below code. Alert is showing the url but not hitting the controller action. Help would be appreciate. Please let me know if you need more information
#model Stud.Areas.Admin.Models.AdminVM
#using Stud.Common.Extension;
<h2>MD Index</h2>
<br />
<div style="margin-top: -45px">
<div class="col-md-12">
<div id="gridDivmsg" style="clear: both;">
<table id="jqGrid" ></table>
<div id="jqGridPagermsg"></div>
</div>
</div>
</div>
#section scripts{
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />
<link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>
<script src="~/Scripts/i18n/grid.locale-en.js"></script>
<script src="~/Scripts/jquery.jqGrid.min.js"></script>
#*<script src="~/Scripts/MDScript.js"></script>*#
#Html.jqGridSetup()
<script>
$(document).ready(function () {
var $grid = $('#jqGrid');
var $gridDiv = $('#gridDivmsg');
function reloadGridmsg() {
var urlName = '#Url.Action("GetMessagesForGrid", "MD")';
$grid.jqGrid("setGridParam", { url: urlName, datatype: "json", page: 1 }).trigger("reloadGridmsg");
$gridDiv.show();
alert(urlName);
}
$grid.jqGrid({
editurl: '#Url.Action("EditRowMessage")',
datatype: 'local',
styleUI: 'Bootstrap',
colNames: ['Id', 'Message Key', 'Message Value', 'Message Status'],
colModel: [
{ name: 'Id', index: 'Id', width: 1, hidden: true, editable: true, edittype: 'text', editrules: { required: true } },
{ name: 'MessageKey', index: 'MessageKey', width: 1, editable: true, edittype: 'text', editrules: { required: true } },
{ name: 'MessageValue', index: 'MessageValue', width: 1, editable: true, edittype: 'textarea', editrules: { required: true } },
{ name: 'MessageStatus', index: 'MessageStatus', width: 1, editable: true, edittype: 'select', editoptions: { value: { 'Active': 'Active', 'InActive': 'InActive' }, defaultValue: 'Active' }, editrules: { required: true } }
],
responsive: true,
loadonce: true,
pager: $('#jqGridPagermsg'),
height: 'auto',
sortname: 'Id',
rowNum: 20,
autowidth: true,
viewrecords: true,
altRows: true,
altclass: 'jqGridAltRow'
});
$grid.jqGrid('filterToolbar', { autosearch: true, searchOnEnter: false, defaultSearch: "cn" });
$grid.jqGrid('navGrid', "#jqGridPagermsg", {
edit: true,
add: true,
del: false,
search: false,
refresh: false,
view: false,
position: "left",
cloneToTop: false
},
{
editCaption: "Edit User",
recreateForm: true,
checkOnUpdate: true,
checkOnSubmit: true,
closeAfterEdit: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText
},
afterComplete: function () {
reloadGridmsg();
}
},
{
addCaption: "Add User",
closeAfterAdd: true,
recreateForm: true,
errorTextFormat: function (data) {
return 'Error: ' + data.responseText
},
afterComplete: function () {
reloadGridmsg();
}
},
{
errorTextFormat: function (data) {
return 'Error: ' + data.responseText
}
});
reloadGridmsg();
});
</script>
}
Controller Action method is as below.
public ActionResult GetMessagesForGrid(StudVM model)
{
if (!IsAuthorized(Enums.Rights.Admin))
return View("NoAccess");
var gridData = _activityService.GetVCRMessagesList();
int totalRecords = gridData.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords / (float)model.rows);
var jsonData = new
{
total = totalPages,
page = model.page,
records = totalRecords,
rows = gridData.Select(d => new { Id = d.Id, cell = new object[] { d.Id, d.MessageKey, d.MessageValue, d.MessageStatus } }).ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
till i'm getting blank grid as below
enter image description here
Your controller is having a parameter model of type StudVM which is not passed in your javascript url.
Try passing parameter of type StudVM. It may resolve your issue.
$grid.jqGrid("setGridParam", { url: urlName,postData: { model:<your model>}, datatype: "json", page: 1 }).trigger("reloadGridmsg");
You need to have the action method follow some method signature as follows
public ActionResult GetMessagesForGrid(string sidx, string sord, int page, int rows, bool _search, string filters)
{
if (!IsAuthorized(Enums.Rights.Admin))
return View("NoAccess");
var gridData = _activityService.GetVCRMessagesList();
int totalRecords = gridData.Count();
int totalPages = (int)Math.Ceiling((float)totalRecords / rows);
var jsonData = new
{
total = totalPages,
page = page,
records = totalRecords,
rows = gridData.Select(d => new { Id = d.Id, cell = new object[] { d.Id, d.MessageKey, d.MessageValue, d.MessageStatus } }).ToArray()
};
return Json(jsonData, JsonRequestBehavior.AllowGet);
}
I also don't see a reason why you don't make the grid datatype to json and specify the url in the begging when you define the grid instead of making the grid client side and then reloading it
$grid.jqGrid({
editurl: '#Url.Action("EditRowMessage")',
datatype: 'json',
url: '#Url.Action("GetMessagesForGrid", "MD")'
styleUI: 'Bootstrap',
colNames: ['Id', 'Message Key', 'Message Value', 'Message Status'],
colModel: [
{ name: 'Id', index: 'Id', width: 1, hidden: true, editable: true, edittype: 'text', editrules: { required: true } },
{ name: 'MessageKey', index: 'MessageKey', width: 1, editable: true, edittype: 'text', editrules: { required: true } },
{ name: 'MessageValue', index: 'MessageValue', width: 1, editable: true, edittype: 'textarea', editrules: { required: true } },
{ name: 'MessageStatus', index: 'MessageStatus', width: 1, editable: true, edittype: 'select', editoptions: { value: { 'Active': 'Active', 'InActive': 'InActive' }, defaultValue: 'Active' }, editrules: { required: true } }
],
responsive: true,
// loadonce: true,
pager: $('#jqGridPagermsg'),
height: 'auto',
sortname: 'Id',
rowNum: 20,
autowidth: true,
viewrecords: true,
altRows: true,
altclass: 'jqGridAltRow'
});
if you need to know how to make that action method custom look at
This solution
Only WWID column is disabled not both columns are disabledenter code here please help me to disable two or more columns
colNames: ['UserName','WWID', 'Generic', 'Mac'],
colModel: [
{ name: 'UserName', index: 'UserName', key: true, width: '200', editable: true, sortable: true, align: 'center' },
{ name: 'WWID', index: 'WWID', width: '250' , editable: true, sortable: true,sorttype:'int', align: 'center' },
{ name: 'Generic', index: 'generic', width:'200', editable: true, sortable: true,sorttype:'text', align: 'center' },
{ name: 'Mac', index: 'mac', width:'200', editable: true, sortable: true,sorttype:'int', align: 'center' },
],
...............
});
jQuery("#gridId").jqGrid('navGrid', '#gridpager',
{ edit: true, add: true, del: true, search: true, excel: true, exceltext: 'Excel', cloneToTop: true },
{ // edit option
url: "Uploading.ashx", closeAfterEdit: true,afterSubmitCell: function () { $('#gridId').trigger('reloadGrid');},
beforeShowForm: function (form) { $('#tr_UserName', form).hide(); },
beforeShowForm: function(form) { $('#tr_WWID', form).hide(); }
},
{ // add option
url: "Uploading.ashx", closeAfterAdd: true,
beforeShowForm: function(form) { $('#tr_UserName', form).show(); },
beforeShowForm: function (form) { $('#tr_WWID', form).show(); }
},
You should provide only one beforeShowForm callback which will show/hide both rows. In your case only the last one provided is being used. Your code should be like this:
jQuery("#gridId").jqGrid('navGrid', '#gridpager',
{ edit: true, add: true, del: true, search: true, excel: true, exceltext: 'Excel', cloneToTop: true },
//Edit options
{
url: "Uploading.ashx",
closeAfterEdit: true,
afterSubmitCell: function () { $('#gridId').trigger('reloadGrid'); },
beforeShowForm: function (form) { $('#tr_UserName', form).hide(); $('#tr_WWID', form).hide(); }
},
//Add options
{
url: "Uploading.ashx",
closeAfterAdd: true,
beforeShowForm: function(form) { $('#tr_UserName', form).show(); $('#tr_WWID', form).show(); }
},
...
);
jQuery("#gridId").jqGrid('navGrid', '#gridpager',
{ edit: true, add: true, del: true, search: true, excel: true, exceltext: 'Excel', cloneToTop: true },
//Edit options
{
url: "Uploading.ashx",
closeAfterEdit: true,
afterSubmitCell: function () { $('#gridId').trigger('reloadGrid'); },
beforeShowForm: function (form) { $('#tr_UserName', form).hide(); $('#tr_WWID', form).hide(); }
},
//Add options
{
url: "Uploading.ashx",
closeAfterAdd: true,
beforeShowForm: function(form) { $('#tr_UserName', form).show(); $('#tr_WWID', form).show(); }
},
...
);
I've been trying to get this to work for days upon days and it seems like one thing after another. Initially, I finally tracked it down to trouble passing ASP.NET dates in the JSON string back to the grid. I am now using JSON.NET and the dates are coming back the way they should be I'm stuck right back where I alwasy seem to be. Here is my code, returned json string, and jqGrid code also: (I'm sorry it's so long, but I just didn't want to leave anything out in case that was the part that was screwing me up)! Basically, I am continually stuck in the success method of the ajax call where I try to addJSONData.... as of right now I am getting an error from Firebug that says:
invalid property id
({total:1,page:1,records:5,[{"ROWID":1,"...rName":"BCC","SubmitterID":"BCC4010","Su
ANY HELP WOULD BE SO GREATLY APPRECIATED! I Want to use this plug in so much, but I am going absolutely nuts trying to make it work!
Thanks in Advance, Briana :-)
WebMethod:
<WebMethod()> _
<Script.Services.ScriptMethod(UseHttpGet:=False, ResponseFormat:=ResponseFormat.Json)> _
Public Function GetTableData() As String
Dim objController As New TradingPartnersController
Dim gv_page As String = String.Empty
Dim sidx As String = String.Empty
Dim sord As String = String.Empty
Dim start As String = String.Empty
Dim limit As String = String.Empty
Dim row As String = String.Empty
Dim header As String = String.Empty
Dim count As Integer = 0
Dim total_pages As Integer = 0
gv_page = HttpContext.Current.Request.Form("page") '.Form("page")
' get the requested page
limit = HttpContext.Current.Request.Form("rows")
' get how many rows we want to have into the grid
sidx = HttpContext.Current.Request.Form("sidx")
' get index row - i.e. user click to sort
sord = HttpContext.Current.Request.Form("sord")
' get the direction
If String.IsNullOrEmpty(sidx) Then
sidx = "PartnerID"
End If
If String.IsNullOrEmpty(sord) Then
sord = "ASC"
End If
If String.IsNullOrEmpty(limit) Then
limit = 10
End If
'' connect to the database
'GridView1.DataSource = objController.ListAll()
'GridView1.DataBind()
Dim objCollection As List(Of TradingPartnersInfo) = objController.ListAll()
count = objCollection.Count
If count > 0 Then
total_pages = Math.Ceiling(count / Int32.Parse(limit))
Else
total_pages = 0
End If
If gv_page Is Nothing Then
gv_page = 1
End If
If Not gv_page > total_pages Then
gv_page = total_pages
End If
start = Math.Ceiling(Int32.Parse(limit) * (Int32.Parse(gv_page) - Int32.Parse(limit)))
If start < 1 Then start = 1
Dim objPageCollection As List(Of TradingPartnersInfo) = objController.ListTradingPartners(sidx, sord, Int32.Parse(start), Int32.Parse(limit))
Dim json As New StringBuilder
json.Append("{")
json.Append("total:" & total_pages.ToString & ",")
json.Append("page:" & gv_page.ToString & ",")
json.Append("records:" & count.ToString & ",")
json.Append(JsonConvert.SerializeObject(objPageCollection))
json.Append("}")
Return json.ToString
End Function
Here is the jqGrid code:
jQuery('table.scroll').jqGrid({
jsonReader: {
root: "rows", //arry containing actual data
page: "page", //current page
total: "total", //total pages for the query
records: "records", //total number of records
repeatitems: false,
id: "ID" //index of the column with the PK in it
},
datatype: function(postdata) {
jQuery.jmsajax({
type: "POST",
url: "EDI.asmx",
method: "GetTableData",
dataType: "msjson",
data: {},
complete: function(data) {
var mygrid = jQuery('table.scroll')[0];
var result = (eval("(" + data.responseText + ")"));
var myjsongrid = (jeval(result.d));
alert(myjsongrid.rows);
mygrid.addJSONData(jeval(myjsongrid.rows)); //This is ERROR LINE
myjsongrid = null;
myjsongridParsed = null;
result = null;
},
success: function(data) {
alert('success: ' + data);
},
error: function(xhr) {
var res = xhr.responseText;
alert(res);
}
});
},
colNames: [
"ROWID",
"ID",
"PartnerID",
"Direction",
"InterchangeVersion",
"InterchangeSenderID",
"InterchangeReceiverID",
"ProductionMode",
"SubmitterName",
"SubmitterID",
"SubmitterPOC",
"CommQual",
"CommNumber",
"ReceiverName",
"ReceiverID",
"PartnerType",
"PartnerNotes",
"IncomingSP",
"OutgoingSP",
"ExchangeAck",
"isDeleted",
"DateTimeInserted",
"KeyID"
],
colModel: [
{ name: "ROWID",
width: 1,
hidden: true,
key: false,
sorttype: 'int',
editrules: { searchhidden: false,
hidedlg: true,
index: 'ROWID',
jsonmap: 'ROWID'
}
},
{ name: "ID",
width: 1,
hidden: true,
key: true,
sorttype: 'int',
editrules: { searchhidden: true,
hidedlg: false,
index: 'ID',
jsonmap: 'ID'
}
},
{ name: "PartnerID",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'PartnerID',
jsonmap: 'PartnerID',
label: 'PartnerID',
resizable: true,
search: true
}
},
{ name: "Direction",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'select',
editoptions: { value: "I:O" },
editrules: { required: true,
index: 'Direction',
jsonmap: 'Direction',
label: 'Direction',
resizable: true,
search: true
}
},
{ name: "InterchangeVersion",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'select',
editoptions: { value: "004010X098A1:004010X097A1:004010X096A1:004010X098A:004010X097A:004010X096A" },
editrules: { required: true,
index: 'InterchangeVersion',
jsonmap: 'InterchangeVersion',
label: 'InterchangeVersion',
resizable: true, search: true
}
},
{ name: "InterchangeSenderID",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'InterchangeSenderID',
jsonmap: 'InterchangeSenderID',
label: 'InterchangeSenderID',
resizable: true,
search: true
}
},
{ name: "InterchangeReceiverID",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'InterchangeReceiverID',
jsonmap: 'InterchangeReceiverID',
label: 'InterchangeReceiverID',
resizable: true,
search: true
}
},
{ name: "ProductionMode",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'select',
editoptions: { value: "T:P" },
editrules: { required: true,
index: 'ProductionMode',
jsonmap: 'ProductionMode',
label: 'ProductionMode',
resizable: true,
search: true
}
},
{ name: "SubmitterName",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'SubmitterName',
jsonmap: 'SubmitterName',
label: 'SubmitterName',
resizable: true,
search: true
}
},
{ name: "SubmitterID",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'SubmitterID',
jsonmap: 'SubmitterID',
label: 'SubmitterID',
resizable: true,
search: true
}
},
{ name: "SubmitterPOC",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'SubmitterPOC',
jsonmap: 'SubmitterPOC',
label: 'SubmitterPOC',
resizable: true,
search: true
}
},
{ name: "CommQual",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: "select",
editoptions: { value: "ED:EM:FX:TE" },
editrules: { required: false,
index: 'CommQual',
jsonmap: 'CommQual',
label: 'CommQual',
resizable: true,
search: true
}
},
{ name: "CommNumber",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: false,
index: 'CommNumber',
jsonmap: 'CommNumber',
label: 'CommNumber',
resizable: true,
search: true
}
},
{ name: "ReceiverName",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'ReceiverName',
jsonmap: 'ReceiverName',
label: 'ReceiverName',
resizable: true,
search: true
}
},
{ name: "ReceiverID",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: true,
index: 'ReceiverID',
jsonmap: 'ReceiverID',
label: 'ReceiverID',
resizable: true,
search: true
}
},
{ name: "PartnerType",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: "select",
editoptions: { value: "Clearinghouse:PPO:Both" },
editrules: { required: true,
index: 'PartnerType',
jsonmap: 'PartnerType',
label: 'PartnerType',
resizable: true,
search: true
}
},
{ name: "PartnerNotes",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'textarea',
editrules: { required: false,
index: 'PartnerNotes',
jsonmap: 'PartnerNotes',
label: 'PartnerNotes',
resizable: true,
search: true
}
},
{ name: "IncomingDataPrepSP",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: false,
index: 'IncomingDataPrepSP',
jsonmap: 'IncomingDataPrepSP',
label: 'IncomingDataPrepSP',
resizable: true,
search: true
}
},
{ name: "OutgoingDataPrepSP",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: 'text',
editrules: { required: false,
index: 'OugoingDataPrepSP',
jsonmap: 'OugoingDataPrepSP',
label: 'OutgoingDataPrepSP',
resizable: true,
search: true
}
},
{ name: "ExchangeAck",
width: 50,
resizable: true,
sortable: true,
sorttype: 'text',
editable: true,
edittype: "select",
editoptions: { value: "True:False" },
editrules: { required: true,
index: 'ExchangeAck',
jsonmap: 'ExchangeAck',
label: 'ExchangeAck',
resizable: true,
search: true
}
},
{ name: "isDeleted",
width: 5,
resizable: false,
sortable: true,
sorttype: 'text',
editable: true,
edittype: "select",
editoptions: { value: "Yes:No" },
editrules: { required: true,
index: 'isDeleted',
jsonmap: 'msg.d.isDeleted',
label: 'isDeleted',
resizable: true,
search: true
}
},
{ name: "DateTimeInserted",
width: 20,
hidden: false,
datefmt: 'Y-m-d',
sorttype: 'date',
editable: false,
editrules: { index: 'DateTimeInserted',
jsonmap: 'DateTimeInserted',
label: 'DateTimeInserted',
resizable: true,
search: true
}
},
{ name: "KeyID",
width: 5,
hidden: true,
key: false,
sorttype: 'int',
editrules: { index: 'KeyID',
jsonmap: 'KeyID',
hidedlg: true,
label: 'KeyID',
resizable: false,
search: false
}
}
],
height: 400,
shrinkToFit: true,
pager: jQuery('#pager'),
rowNum: 10,
rowList: [10, 20, 30, 40, 50],
sortname: 'ROWID',
sortorder: "asc",
viewrecords: true,
imgpath: 'http://localhost/DNN5/js/jQuery/jqGrid-3.4.3/themes/sand/images',
caption: 'X12 Trading Partners',
viewrecords: true,
gridComplete: function() {
alert("i'm grid complete" + JSON.stringify(msg));
//updates the new column order position
$('table.scroll').tableDnDUpdate();
}}).navGrid('table.scroll', { edit: true, add: true, del: true }).tableDnD();
Here is the Returned JSON String: (I have no problem seeing this data being returned to client.)
success:
{total:1,page:1,records:5,[{"ROWID":1,"ID":1,"PartnerID":"BCN","Direction":"I","InterchangeVersion":"004010X096A1","InterchangeSenderID":"BCC4010","InterchangeReceiverID":"company","ProductionMode":"T","SubmitterName":"BCC","SubmitterID":"BCC4010","SubmitterPOC":"BCC","CommQual":"","CommNumber":"","ReceiverName":"company","ReceiverID":"BCC4010","PartnerTypes":"","PartnerNotes":"","IncomingDataPrepSP":"","OutgoingDataPrepSP":"","ExchangeAck":false,"DateTimeInserted":new Date(1214412777787),"IsDeleted":false},{"ROWID":2,"ID":2,"PartnerID":"BCN","Direction":"I","InterchangeVersion":"004010X098A1","InterchangeSenderID":"BCC4010","InterchangeReceiverID":"company","ProductionMode":"T","SubmitterName":"BCC","SubmitterID":"BCC4010","SubmitterPOC":"BCC","CommQual":"","CommNumber":"","ReceiverName":"company","ReceiverID":"BCC4010","PartnerTypes":"","PartnerNotes":"","IncomingDataPrepSP":"","OutgoingDataPrepSP":"","ExchangeAck":false,"DateTimeInserted":new Date(1212088125000),"IsDeleted":false},{"ROWID":3,"ID":3,"PartnerID":"BCN","Direction":"O","InterchangeVersion":"004010X091A1","InterchangeSenderID":"HCA770385729","InterchangeReceiverID":"BCC47198 ","ProductionMode":"T","SubmitterName":"company Administrators","SubmitterID":"HCA770385729","SubmitterPOC":"briana","CommQual":"EM","CommNumber":"briana#company.com","ReceiverName":"BCN","ReceiverID":"BCC47198","PartnerTypes":"","PartnerNotes":"","IncomingDataPrepSP":"","OutgoingDataPrepSP":"","ExchangeAck":false,"DateTimeInserted":new Date(1212088125547),"IsDeleted":false},{"ROWID":4,"ID":4,"PartnerID":"EHG","Direction":"I","InterchangeVersion":"004010X097A1","InterchangeSenderID":"330989922","InterchangeReceiverID":"company","ProductionMode":"T","SubmitterName":"DENTALCONNECT","SubmitterID":"330989922","SubmitterPOC":"","CommQual":"","CommNumber":"","ReceiverName":"","ReceiverID":"","PartnerTypes":"Clearinghouse","PartnerNotes":"Dental clearinghouse. Sends billing address in the pay-to segment (NM1*87) and the service address in the billing segment (NM1*85).","IncomingDataPrepSP":"[dispatch].spPreprocessEHG","OutgoingDataPrepSP":"","ExchangeAck":true,"DateTimeInserted":new Date(1235603192033),"IsDeleted":false},{"ROWID":5,"ID":5,"PartnerID":"EMDEON","Direction":"I","InterchangeVersion":"004010X097A1","InterchangeSenderID":"341884003","InterchangeReceiverID":"857297703","ProductionMode":"T","SubmitterName":"INTERACTIVE PAYER NETWORK","SubmitterID":"341884003","SubmitterPOC":"","CommQual":"","CommNumber":"","ReceiverName":"","ReceiverID":"","PartnerTypes":"Clearinghouse","PartnerNotes":"Dental clearinghouse. Sends billing address in the pay-to segment (NM1*87) and the service address in the billing segment (NM1*85).","IncomingDataPrepSP":"","OutgoingDataPrepSP":"","ExchangeAck":true,"DateTimeInserted":new Date(1235603192000),"IsDeleted":false}]}
Actually, tvanfosson makes an excellent point with the requirement of the 'rows' identifier. I'm unfamiliar with jMSAjax so my comments may be null and void. I'm glad to be aware of it.
Could it be something as simple as the return type being string? That is, when the response is evaluated, you end up with the encapsulated string not the json object.
I've been in a similar place myself. I found the options to be either, create a business object that represents the expected jqGrid response and return the object not a string (ASP.NET will serialize it as JSON for you!) or modify the jqGrid to eval the response twice (messy).
missing an identifier for that list:
return_value = {
total:1,
page:1,
records:5,
[{ .. some X12 messages ..}]
}
I have spent a lot of time trying to get jqGrid to work with ASP.NET using JSON. Now that I have it working, I would like to share it with you. Hoping to save time for other people.
I found the answer here. This is not to say there are no other ways to make this work (I'm sure there are). But this one definitely works.
To summarize the things that made a difference for me:
Using "datatype: function() {" on the settings of the jqGrid, and NOT using "datatype: json". The function uses "$.ajax(" to call the service. Looking in Fiddler, this changed the data coming back to the browser, to be pure JSON (instead of JSON wrapped in XML).
Using a web service that returns a
data class (in the schema jqGrid
expects). I first tried using JSON.NET
but for some reason the message
showed (in Fiddler again) to be
escaped with \ for every quote in the
string. I'm pretty sure you can get
JSON.NET to work. But it works just
as well without it.
It doesn't look like you are adding the rows property identifier. Try changing:
json.Append(JsonConvert.SerializeObject(objPageCollection))
to
json.Append("rows: " + JsonConvert.SerializeObject(objPageCollection))
If this doesn't work, I suggest that you simplify the problem -- reduce the data to one row, for example -- and see if you can get it working with simpler data, then gradually add more stuff back into it.