【问题标题】:Webgrid disappear while clicking pagination in MVC3在MVC3中单击分页时Webgrid消失
【发布时间】:2013-04-21 11:14:21
【问题描述】:

我的主cshtml中有一个网格作为部分视图。当我单击网格中的页码时,网格正在消失。有什么建议吗?

Devices.csthml(部分视图)

即使我在局部视图中有 div my-grid。

<div id="my-grid">
    @{

        var grid = new WebGrid(
                               canPage: true,
                               canSort: true,
                             rowsPerPage: 3,
                             ajaxUpdateContainerId: "my-grid");

            grid.Bind(Model, rowCount: Model.Count(), autoSortAndPage: true);



        @grid.GetHtml(
        htmlAttributes: new { id = "my-grid" },
        tableStyle: "grid1",
        headerStyle: "header",
        rowStyle: "row",
        footerStyle: "footer",
        alternatingRowStyle: "altRow",
        columns: grid.Columns(
                                grid.Column("ObjectOfServiceName", "Device Name", style: "textCol"),
                                grid.Column("SerialNumber", "Serial Number", style: "textCol"),
                                grid.Column("ContractIdentifier", "Contract Identifier", style: "textCol"),
                                grid.Column("ServiceLevelCode", "Service Level", style: "textCol"),
                                grid.Column("UserDeviceDescription", "Device Grouping", style: "textCol"),
                                grid.Column(header: "", format: @<text>@Html.ActionLink("Upgrade", "DeviceUpgradePartial", new { objectOfServiceId = item.ObjectOfServiceId, serviceContractId = item.ServiceContractId, serialNumber = item.SerialNumber, objectOfServiceName = item.ObjectOfServiceName, serviceLevelId = item.ServiceLevelId, deviceGroupingId = item.DeviceGroupingId }, new { @class = "upgradeLink", title = "Upgrade Device" })" </text>, style: "colOperation"),
                                grid.Column(header: "", format: @<text>@Html.ActionLink("Update", "DeviceUpdatePartial", new { objectOfServiceId = item.ObjectOfServiceId, serviceContractId = item.ServiceContractId, serialNumber = item.SerialNumber, objectOfServiceName = item.ObjectOfServiceName, serviceLevelId = item.ServiceLevelId, deviceGroupingId = item.DeviceGroupingId }, new { @class = "updateLink", title = "Update Device" })" </text>, style: "colOperation"),
                                grid.Column(header: "", format: @<text>@Html.ActionLink("ReassignDeviceGroup", "ReassingDeviceGroupingPartial", new { objectOfServiceId = item.ObjectOfServiceId, serviceContractId = item.ServiceContractId, serialNumber = item.SerialNumber, objectOfServiceName = item.ObjectOfServiceName, serviceLevelId = item.ServiceLevelId, deviceGroupingId = item.DeviceGroupingId }, new { @class = "reassingDeviceGroupLink", title = "Update Device" })" </text>, style: "colOperation")

                            ), mode: WebGridPagerModes.All)




    }
</div>

Main.cshtml:

 <tr>
                @using (Html.BeginForm())
                {

                    <td>Select customer Name</td>
                    <td>

                        @Html.DropDownListFor(m => m.customer_id, new SelectList(Model.customerList, "customer_id", "customer_business_name"))
                        <input type="hidden" id="hdnCustomerName" name="hdnCustomerName" />
                        <input type="hidden" id="hdnShowHideCustInfo" name="hdnShowHideCustInfo" />
                        <input type="submit" value="Go" name="Go" id="Go" />
                       </td>                   

                }
            </tr>

        </table>

    </div>




        @if (Model.objectOfServiceListDevice != null)
        {
            @Html.Partial("Devices", Model.objectOfServiceListDevice)
        }

【问题讨论】:

    标签: asp.net-mvc-3 webgrid


    【解决方案1】:

    我会尝试替换这个:

    @if (Model.objectOfServiceListDevice != null)
    {
        @Html.Partial("Devices", Model.objectOfServiceListDevice)
    }
    

    有了这个:

    <div id="myGrid">
        @Html.Partial("Devices", Model.objectOfServiceListDevice)
    </div>
    

    【讨论】:

      猜你喜欢
      • 2013-01-16
      • 2013-10-09
      • 2012-05-02
      • 2011-09-14
      • 2013-05-09
      • 1970-01-01
      • 1970-01-01
      • 2011-10-05
      • 2012-02-15
      相关资源
      最近更新 更多