如何使asp.net gridview的footable分页工作? [英] How to make footable pagination work with asp.net gridview?

查看:626
本文介绍了如何使asp.net gridview的footable分页工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Footable是jQuery的响应数据表的插件,当我试图用asp.net GridView控件组件一起使用它,我不得不分页插件安装到表的底部有问题。

Footable is a plugin for jQuery responsive data tables, when I tried to use it together with asp.net GridView component, I had a problem to attach the pagination plugin to the bottom of the table.

Footable教程说要自定义添加分区表中的

Footable tutorial says to add a custom div to the tfoot element of the table

<div class="pagination pagination-centered hide-if-no-paging"></div>

但问题是,如何把TFOOT标签内这个自定​​义HTML,为GridView控件自动生成HTML全?你可以用asp.net并不简单放HTML在一起,所以我不得不作出一个解决办法的方法来产生内部TFOOT的code。我希望这将有助于有人在将来,当余did't发现任何类似的解决这个特殊的问题。

But the problem is, how to put this custom html inside tfoot tag, as GridView automatic generates the whole html? You can't simple put html together with asp.net, so I had to make a workaround method to generate the code inside tfoot. I hope it will help someone in the future, as I did't find any similar solution to this particular problem.

推荐答案

要解决这个问题我适应的方法,我发现在这里:<一href=\"http://stackoverflow.com/questions/315178/asp-net-gridview-newbie-questions-about-tfoot-and-th\">ASP.NET GridView的新手问题关于TFOOT和TH

To solve the problem I adapted a method I found here: ASP.NET GridView Newbie Questions About TFOOT and TH

要包含分页所需的定制div标签,其结果是:

To include the custom div tag required for pagination, the result was:

    protected void onRowCreate(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            int colSpan = e.Row.Cells.Count;

            for (int i = (e.Row.Cells.Count - 1); i >= 1; i -= 1)
            {
                e.Row.Cells.RemoveAt(i);
                e.Row.Cells[0].ColumnSpan = colSpan;
            }

            e.Row.Cells[0].Controls.Add(new LiteralControl("<ul class='pagination pagination-centered hide-if-no-paging'></ul>"));
        }
    }

和所谓的它GridView的声明,在onRowCreated

And so called it on GridView declaration, at 'onRowCreated'

 <asp:GridView ID="gridViewClientes" ShowFooter="true" OnRowCreated="onRowCreate">

不要忘了把这个表prerender,正确地创建TFOOT:

Dont forget to call this on tablePrerender, to create TFOOT correctly:

gridViewClientes.FooterRow.TableSection = TableRowSection.TableFooter;

请注意:我其实是有从footable例如DIV元素更改为UL元素才能正常工作。

NOTE: I actually had to change the DIV element from footable example to a UL element in order to work correctly.

这篇关于如何使asp.net gridview的footable分页工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆