我是Jquery和JSon的新手,并试图将JSON数组结果绑定到JQGrid。
我可以在Controller中看到JSON结果,但在视图中没有绑定。
请帮我处理我的代码。可能我在视图中的函数中遗漏了
这是单击按钮加载结果时的功能提升
function LoadOrganisationGrid() {
var predifnedValue = $("#cmdOrgList").val();
jQuery("#gridOrganisation").jqGrid({
url: 'Home/GetOrganisationGridResults?predefinedMatchID=' + predifnedValue,
datatype: "json",
mtype: 'GET',
width: 1030,
height: 275,
colNames: ['Org_MID', 'P_MID', 'Candidate_Detail', 'CompanyName', 'StreetAddress', 'City', 'PostCode', 'Country', 'EmailDomain', 'VATNo', 'IsLinked', 'NotLinked'],
colModel: [
{ name: 'Org_MatchCandidateID', index: 'Org_MatchCandidateID', width: 60 },
{ name: 'PredefinedMatchID', index: 'PredefinedMatchID', width: 50 },
{ name: 'Candidate_Detail', index: 'Candidate_Detail', width: 150 },
{ name: 'CompanyName', index: 'CompanyName', width: 100, align: "right" },
{ name: 'StreetAddress', index: 'StreetAddress', width: 150, align: "right" },
{ name: 'City', index: 'City', width: 50, align: "right" },
{ name: 'PostCode', index: 'PostCode', width: 80, sortable: false },
{ name: 'Country', index: 'Country', width: 60, sortable: false },
{ name: 'EmailDomain', index: 'EmailDomain', width: 100, sortable: false },
{ name: 'VATNo', index: 'VATNo', width: 50, sortable: false },
{ name: 'Count_IsLinked', index: 'Count_IsLinked', width: 90, sortable: false },
{ name: 'Count_NotLinked', index: 'Count_NotLinked', width: 90, sortable: false }
],
rowNum: 10,
rowList: [10, 20, 30],
pager: '#pager5',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption: "Organisations Data"
}).navGrid("#pager5", { edit: false, add: false, del: false });
}
以下控制器代码
public JsonResult GetOrganisationGridResults(int predefinedMatchID)
{
var result = new SearchTypeModel
{
ListOrganisationType = GetOrgansiationList(SearchTypeService.GetOrganisationType(predefinedMatchID))
};
return Json(result, JsonRequestBehavior.AllowGet);
}
查看以下代码
<table id="gridOrganisation" ></table>
<div id="pager5"></div>