【问题标题】:Implement bootstrap pagination in webgrid在 webgrid 中实现引导分页
【发布时间】:2017-06-03 02:55:27
【问题描述】:

我想用 bootstrap 设置 Webgrid 分页的样式,但找不到任何好方法。

我找到了这个包https://www.nuget.org/packages/WebGridBootstrapPagination/ 但是安装后我不知道如何使用它。

这是我的 webgrid 的一部分

@model IEnumerable<AnalyticConfig.Models.User>
@{
  var grid = new WebGrid(Model, ajaxUpdateContainerId: "ajaxgrid",    ajaxUpdateCallback: "webgrid", rowsPerPage: 5);
  grid.Pager(WebGridPagerModes.All);
}


    <div id="ajaxgrid" class="row panel-body table-responsive">
    @grid.GetHtml(
    tableStyle: "table table-striped table-list table-hover",
    columns: grid.Columns(
                grid.Column(canSort: false, style: "col-md-2", format: 
                @<text>
                    <a href='#' class="btn btn-info glyphicon glyphicon-pencil display edit-btn"></a>
                    <a href="#" class="btn btn-success glyphicon glyphicon-ok modify save-btn"></a>
                    <a href="#" class="btn btn-warning glyphicon glyphicon-remove modify cancel-btn"></a>
                    <a href="#" class="btn btn-danger glyphicon glyphicon-trash display delete-btn"></a>
                </text>),
                grid.Column(null, null, style:"hidecol", format: @<input type="hidden" id="in_ID" value="@item.Id" />),
                grid.Column("SchoolUnit", "Skolenhet", style: "col-md-2", format:
                @<text>
                    <span class="display"><label id="lbl_unit">@item.SchoolUnit</label></span>
                    @Html.DropDownList("in_unit", new SelectList(ViewBag.schoolUnitList, "Text", "Value", @item.SchoolUnit), new { @class = "form-control modify" })
                </text>),
                grid.Column("Name", "Namn", style: "col-md-2", format:
                 @<text>
                    <span class="display"><label id="lbl_name">@item.Name</label></span>
                    <input type="text" id="in_name" value="@item.Name" class="form-control modify" />
                </text>)

    )
    </div>

如果您知道如何使用该软件包或知道任何其他方式,请告诉我。

【问题讨论】:

    标签: asp.net twitter-bootstrap webgrid


    【解决方案1】:

    我的解决方案。没有为 webgrid 分页添加自定义 css 或 html

    $("tfoot a").addClass('btn btn-default'); // add bootstrap buttons
    
    // add active bootstrap button
    $("tfoot td")
      .contents()
      .filter(function () {     
          if (this.nodeType === 3 && this.length > 1) {
              return this.nodeType
          }
      })
      .wrap('<span class="btn btn-primary" />');
    

    结果

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-08
      • 2018-09-22
      • 2012-05-14
      • 2013-10-09
      • 2012-09-15
      • 2020-03-07
      • 1970-01-01
      相关资源
      最近更新 更多