展开Main jqGrid行时,将构建并显示一个子网格。在构造子网格之前,我需要捕获主网格扩展的行列数据。为此,我正在使用Main Grid的subGridBeforeExpand事件。在那种情况下,我正在调用javascript代码以捕获扩展的行列数据,但没有成功。警报将sel_id抛出为null。有人可以指导我吗?我是否需要使用另一个网格事件或我的jquery代码有问题?
**<script type="text/javascript">
function GetValues() {
var sel_id = jQuery("#ServersWS").jqGrid('getGridParam', 'selrow');
alert(sel_id);
var rowData = jQuery("#ServersWS").jqGrid('getRowData', sel_id);
var temp = rowData['Description']; //replace name with you column
alert(temp);
}
</script>**
div id="gridWrapper1" style="display: none">
@{
var grid1 = new JqGridHelper<Configuration.Models.Post.ProfileModel>(
"ServersWS",
caption: "Server Profiles With One or More Settings",
hidden: false,
hiddenEnabled: true,
dataType: JqGridDataTypes.Json,
methodType: JqGridMethodTypes.Post,
pager: true,
rowsNumber: 10,
sortingName: "Profile",
sortingOrder: JqGridSortingOrders.Asc,
url: Url.Action("GetServersWithSettings"),
**subGridBeforeExpand: "function(id) {GetValues();}",**
subgridEnabled: true,
subgridHelper: new JqGridHelper<PlatformConfigurationEditModel>(
"ProfileSettingsEdit",
caption: "Edit Settings",
hidden: false,
hiddenEnabled: true,
dataType: JqGridDataTypes.Json,
methodType: JqGridMethodTypes.Post,
pager: true,
rowsNumber: 10,
sortingName: "Id",
sortingOrder: JqGridSortingOrders.Asc,
url: Url.Action("GetEditableProfileSettings"),
editingUrl: Url.Action("Edit"),
viewRecords: true,
autoWidth: true,
sortable: true)
.Navigator(new JqGridNavigatorOptions { Search = false },
new JqGridNavigatorEditActionOptions { Url = Url.Action
("Update"),CloseAfterAdd = true, CloseAfterEdit = true, Width = 500, Height
= 300 },
new JqGridNavigatorEditActionOptions { Url = Url.Action("Add"),
CloseAfterAdd = true, CloseAfterEdit = true, Width = 500, Height = 300 },
new JqGridNavigatorDeleteActionOptions { Url = Url.Action("Delete") },
null, new JqGridNavigatorViewActionOptions { LabelsWidth = "60%" }
)
.FilterToolbar(options: new JqGridFilterToolbarOptions
{
StringResult = true,
DefaultSearchOperator = JqGridSearchOperators.Cn,
AutoSearch = true,
SearchOnEnter = false
}),
sortable: true
).FilterToolbar(new JqGridFilterToolbarOptions
{
StringResult = true,
DefaultSearchOperator = JqGridSearchOperators.Cn,
AutoSearch = true,
SearchOnEnter = false,
});
@grid1.GetHtml()
}
</div>
最佳答案
我不熟悉Lib.Web.Mvc库,但是您可以尝试使用jQuery events而不是callbacks。例如,jqGridSubGridBeforeExpand
可能是您需要的:
jQuery("#ServersWS").bind("jqGridSubGridBeforeExpand", function (e, pID, rowid) {
alert("rowid=" + rowid);
});