0

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

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

 <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>

感谢您的帮助!

4

0 回答 0