嘿那里Stack Overflow爱好者。我有一个jqGrid网格,我想从我放入viewData存储库的JSON数据填充。我怎样才能做到这一点?
到目前为止,我所拥有的只是...... 更新:我现在尝试点击控制器方法,而不是通过viewData
传递数据 $("#results").jqGrid({
shrinkToFit: false,
autowidth: false,
width: 800,
datatype: 'jsonsstring',
url:'<%=Url.Action("getGrid", "Log", new { physSearch = Model})%>',
//datastr: $.jgrid.htmlEncode('@ViewData["ResultData"]'),
mtype: 'POST',
colNames:
[
'Sent Time',
'Recipient',
'EPCD ID',
'Address',
'Channel',
'Sent Status',
'Document ID',
'MRN',
'Patient Name',
'Pages',
'Message Log ID',
'Orginial Message Log ID',
'Message ID',
'Message Type',
'Sender',
'Comments'
],
colModel:
[
{ name: 'Sent_Time', width: 115 },
{ name: 'Recipient', width: 115 },
{ name: 'EPCD_ID', width: 115 },
{ name: 'Address', width: 115 },
{ name: 'Channel', width: 115 },
{ name: 'Sent_Status', width: 115 },
{ name: 'Document_ID', width: 115 },
{ name: 'MRN', width: 115 },
{ name: 'Patient_Name', width: 115 },
{ name: 'Pages', width: 115 },
{ name: 'Message_Log_ID', width: 115 },
{ name: 'Orginial_Message_Log_ID', width: 115 },
{ name: 'Message_ID', width: 115 },
{ name: 'Message_Type', width: 115 },
{ name: 'Sender', width: 115 },
{ name: 'Comments', width: 115 }
],
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Id',
sortorder: "desc",
loadui: 'block',
loadtext: 'Results Grid',viewrecords: true,
imgpath: '/Content/themes/UPMC-theme/images',
caption: 'Patient Return Result',
ondblClickRow: function (id) { }
})
答案 0 :(得分:1)
试试这样:
datatype: 'json',
datastr: @Html.Raw(Json.Encode(ViewData["ResultData"]))