如何获取jqGrid选择的行列数据并重置子网格导航URL

时间:2013-09-27 05:30:27

标签: jquery asp.net-mvc jquery-ui asp.net-mvc-4 jqgrid

嗨 - 我还有两个问题需要更多时间来理解和解决。

当我展开Main jqGrid行时,我需要能够通过将选择行列值附加为查询字符串来获取所选行列单元格值并重置子网格导航URL(编辑,添加,删除等..)。因此,当用户编辑子网格项或向子网格添加新项时,控制器应从选定的主网格行接收列值。我正在使用subGridBeforeExpand事件捕获主网格选定的行数据,并修改子网格导航属性,如设置编辑,添加等网址。

 <script type="text/javascript">
    function GetAndReset(id) {

          //Not sure how to get selected row column values . I looked into online with various 
         examples of using getRowdata etc but nothing worked.

         //Need to reset the subgrid navig edit,add,delete urls
         jQuery("#ProfileSettingsEdit").jqGrid('navGrid', '#gridpager', {}, { url: url }, { url: 
         url }, {}, {}, {});

    }
  </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) {GetAndReset(id);}",
            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>

感谢您的帮助!

0 个答案:

没有答案