【问题标题】:WebGrid Paging not workingWebGrid 分页不起作用
【发布时间】:2018-11-10 03:53:11
【问题描述】:

我有一个下拉和按钮控件,点击按钮我正在绑定 WebGrid,它工作正常,加载网格将为空,但绑定后网格分页不起作用,下面是我的代码

@using (Html.BeginForm("EmpLog", "Labels", FormMethod.Post))
{
  @Html.DropDownListFor(x => x.SelectedValue, Model.Values, "----Select----", new { id = "ddlName", @class = "form-control col-md-6" })
  <input type="submit" value="Search" id="btnSearch" class="btn btn-default" />

  @{
     var gridview = new WebGrid(source: Model.LstLog, rowsPerPage: 20, ajaxUpdateContainerId: "grid", canSort: false);
   }

  @if (Model.Lst != null)
   {
     @gridview.GetHtml(
                  htmlAttributes: new { id = "gridlogs" },
                  fillEmptyRows: false,
                  alternatingRowStyle: "alternate-row",
                  headerStyle: "grid-header",
                  footerStyle: "grid-footer",
                  selectedRowStyle: "grid-selected-row",
                  rowStyle: "grid-row-style",
                  mode: WebGridPagerModes.All,
                  firstText: "<< First",
                  previousText: "< Prev",
                  nextText: "Next >",
                  lastText: "Last >>",
                  columns: new[] {
                  gridview.Column("View", header: null, style: "click_able", format: @<text><a href="javascript:ViewFullDetails('@item.Id');">View</a></text>, canSort: false),
                  gridview.Column("JoinDate",header: "Join Date"),
                  gridview.Column("DeptName",header: "Dept Name"),
                  gridview.Column("Project",header: "Project")
                 }
             )}
    }

    [HttpGet]
    public ActionResult EmpLog()
    {
         model.Values = GetDDLInfo();
         return View();
    }

    [HttpPost]
    public ActionResult EmpLog()
    {
         model.Values = GetDDLInfo();
         model.LstLog= GetLogInfo();
         return View(model);
    }

我对 WebGrid 不够好,请帮我在其中应用分页。

【问题讨论】:

    标签: c# asp.net-mvc webgrid


    【解决方案1】:

    我已经添加了下面的代码来工作分页

    $('th a, tfoot a').click(function () {
        $('form').attr('action', $(this).attr('href')).submit();
        return false;
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-28
      • 2018-03-12
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      相关资源
      最近更新 更多