我想在行的JqGrid中使用链接。此链接从Row的单击获取id并重定向到另一个页面并显示另一个JqGrid。 我使用这段代码:
<script type="text/javascript">
var searchOptions = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', 'bw', 'bn', 'in', 'ni', 'ew', 'en', 'cn', 'nc'];
$(document).ready(function () {
$('#list').jqGrid({
caption: "ObisData",
//url from wich data should be requested
url: '@Url.Action("GetObisData", "DataGrid")',
//EditData
editurl: '@Url.Action("EditData", "DataGrid")',
//type of data
datatype: 'json',
jsonReader: {
root: "Rows",
page: "Page",
total: "Total",
records: "Records",
repeatitems: true,
id: "ObisDataID",
cell: "RowCells",
subgrid: { root: "Rows", repeatitems: true, cell: "RowCells" }
},
//url access method type
mtype: 'POST',
//columns names
colNames: ['', 'power', 'water', 'serial M', 'serial C', 'Date', ''],
//columns model
colModel: [
{
name: 'ObisDataID', index: 'ObisDataID', align: 'right', width: 100,
editable: false, hidden: true, key: true
},
{
name: 'MeterPowerSharingNo', index: 'MeterPowerSharingNo', align: 'center', width: 100,
editable: false, hidden: false
},
{
name: 'MeterWaterSharingNo', index: 'MeterWaterSharingNo', align: 'center', width: 100,
editable: false, hidden: false
}
,
{
name: 'ModemSerial', index: 'ModemSerial', align: 'center', width: 100,
editable: false, hidden: false
},
{
name: 'MeterSerial', index: 'MeterSerial', align: 'center', width: 100,
editable: false, hidden: false
}
,
{
name: 'MessageDate', index: 'MessageDate', align: 'center', width: 170,
editable: false, hidden: false
},
{
name: 'EditAction', index: 'EditAction', align: 'center', width: 170,
formatter: function (cellvalue, options, rowObject) {
return "<a href='/DataGrid/GetAllObisData'><u>Show Detail</u></a>";
}
}
],
//pager for grid
pager: $('#pager'),
//number of rows per page
rowNum: 10,
rowList: [10, 20, 50, 100],
//initial sorting column
sortname: 'ObisDataID',
//initial sorting direction
sortorder: 'desc',
//we want to display total records count
viewrecords: true,
altRows: true,
shrinkToFit: false,
width: '900',
height: 'auto',
hidegrid: false,
direction: "rtl",
gridview: true,
rownumbers: true,
footerrow: true,
//userDataOnFooter: true,
loadComplete: function () {
//change alternate rows color
$("tr.jqgrow:odd").css("background", "#E0E0E0");
},
loadError: function (xhr, st, err) {
jQuery("#rsperror").html("Type: " + st + "; Response: " + xhr.status + " " + xhr.statusText);
},
subGrid: true,
subGridModel: [{
name: ['Data', 'translate'],
width: [150, 150],
align: ['center', 'center']
}],
subGridOptions: {
reloadOnExpand: false //load only once
},
subGridUrl: '@Url.Action("GetSubGridObisData", "DataGrid")'
});
});
但点击“显示详细信息”时出错。
参数字典包含参数'page'的参数'page'的空条目,用于方法'System.Web.Mvc.ActionResult GetAllObisData(System.String,System.String,Int32,Int32)的非可空类型'System.Int32' ,“布尔,System.String,System.String,System.String,System.String)”在'MeterControl.Controllers.Grids.DataGridController'中。可选参数必须是引用类型,可空类型,或者声明为可选参数“