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

Javascript 如何获取扩展的jqGrid行-列数据,javascript,jquery,asp.net,asp.net-mvc,jqgrid,Javascript,Jquery,Asp.net,Asp.net Mvc,Jqgrid,展开主jqGrid行时,将构造并显示子网格。在构建子网格之前,我需要捕获主网格扩展的行-列数据。为此,我使用主网格的subGridBeforeExpand事件。在这种情况下,我调用一个javascript代码来捕获扩展的行-列数据,但没有成功警报将选择id抛出为null。谁能给我指点一下吗?。我的jquery代码是否需要使用另一个网格事件或其他错误 **<script type="text/javascript"> function GetValues() {

展开主jqGrid行时,将构造并显示子网格。在构建子网格之前,我需要捕获主网格扩展的行-列数据。为此,我使用主网格的subGridBeforeExpand事件。在这种情况下,我调用一个javascript代码来捕获扩展的行-列数据,但没有成功警报将选择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>
**
函数GetValues(){
var sel_id=jQuery(“#ServersWS”).jqGrid('getGridParam','selrow');
警报(sel_id);
var rowData=jQuery(“#ServersWS”).jqGrid('getRowData',sel#u id);
var temp=rowData['Description'];//用列替换名称
警报(临时);
}
**     
div id=“gridWrapper1”style=“display:none”>
@{
var grid1=新的JqGridHelper(
“服务器SWS”,
标题:“具有一个或多个设置的服务器配置文件”,
隐藏:假,
hiddenEnabled:对,
dataType:JqGridDataTypes.Json,
methodType:JqGridMethodTypes.Post,
寻呼机:是的,
世界其他地区成员:10,
排序名称:“配置文件”,
排序顺序:JqGridSortingOrders.Asc,
url:url.Action(“GetServersWithSettings”),
**subGridBeforeExpand:“函数(id){GetValues();}”**
subgridEnabled:true,
subgridHelper:新的JqGridHelper(
“ProfileSettingsEdit”,
标题:“编辑设置”,
隐藏:假,
hiddenEnabled:对,
dataType:JqGridDataTypes.Json,
methodType:JqGridMethodTypes.Post,
寻呼机:是的,
世界其他地区成员:10,
排序名称:“Id”,
排序顺序:JqGridSortingOrders.Asc,
url:url.Action(“GetEditableProfileSettings”),
editingUrl:Url.Action(“编辑”),
viewRecords:是的,
自动宽度:正确,
可排序:true)
.Navigator(新的JqGridNavigatorOptions{Search=false},
新的JqGridNavigatorEditActionOptions{Url=Url.Action
(“更新”),CloseAfterAdd=true,CloseAfterEdit=true,宽度=500,高度
= 300 },
新的JqGridNavigatorEditActionOptions{Url=Url.Action(“添加”),
CloseAfterAdd=true,CloseAfterEdit=true,宽度=500,高度=300},
新的JqGridNavigatorDeleteActionOptions{Url=Url.Action(“Delete”)},
空,新的JqGridNavigatorViewActionOptions{LabelsWidth=“60%”
)
.FilterToolbar(选项:新JqGridFilterToolbarOptions
{
StringResult=true,
DefaultSearchOperator=JqGridSearchOperators.Cn,
自动搜索=真,
searchoneter=false
}),
可排序:正确
).FilterToolbar(新JQGridFilterToolBar选项
{
StringResult=true,
DefaultSearchOperator=JqGridSearchOperators.Cn,
自动搜索=真,
searchOnner=false,
});
@grid1.GetHtml()
}
我不熟悉库,但您可以尝试使用而不是。例如,
jqGridSubGridBeforeExpand
可能是您所需要的:

jQuery(#ServersWS”).bind(“jqgridsubgridbeforexpand”,函数(e,pID,rowid){
警报(“rowid=“+rowid”);
});

Hi-Oleg您能对此进行调查吗?@OlegHi感谢您的回复-如何使用rowid获取扩展的行-列数据@OlegTrying这个有效的-jQuery(#ServersWS”).bind(“jqGridSubGridBeforeExpand”,function(e,pID,rowid){var rowData=jQuery(#ServersWS”).jqGrid('getRowData',rowid);var temp=rowData['Description'];//用列警报(temp)替换名称);嗨@Oleg这是解决另一个问题的第一步。如何修改子网格导航属性?具体来说,我需要修改编辑、添加、删除url,比如jQuery(“#ProfileSettingsEdit”).jqGrid('navGrid','#gridpager',{},{url:url},{url:url},{},{url:url},{},{},{})@用户845405:不客气!我不理解你的最后一个问题,因为你通常会创建一个网格作为子网格,它的导航栏直接位于
subgridbeforexpand
callback中。可能是特定的Lib.Web.Mvc问题?