gpt4 book ai didi

javascript - 如何获取扩展的jqGrid行列数据

转载 作者:行者123 更新时间:2023-12-02 18:18:28 25 4
gpt4 key购买 nike

当主 jqGrid 行展开时,将构造并显示子网格。我需要在构建子网格之前捕获主网格扩展行列数据。为此,我使用主网格的 subGridBeforeExpand 事件。在这种情况下,我调用 JavaScript 代码来捕获扩展的行列数据,但没有成功。 警报将 sel_id 抛出空。任何人都可以指导我吗?我需要使用另一个网格事件还是我的 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);
});

关于javascript - 如何获取扩展的jqGrid行列数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19054071/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com