引言

项目中使用jquery插件 jquery.tablesorter 对Table进行排序时,GridView Render出来的代码让人心情很不爽。默认的HTML结构是需要<thead /> 标签的。结果导致tablesort不能使用。

 

GridView Render <thead /> 标签吗?

默认情况(vs2008)是不会呈现 <thead /> <tbody /> <tfoot /> 标签。

 

解决方案

方案一:修改jquery.tablesorter 插件,使其没有thead标签的时候也能使用。(没有实现)

 

方案二:想方设法让GridView Render 出 <thead /> 等标签,迎合jquery.tablesorter的默认结构。

 

GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;

 

在 GridView1 绑定数据源以后,添加上面一行代码,GridView 就可以Render出<thead />标签,问题迎刃而解。

 

方案三:使用jquey给表格的第一行包装<thead />标签,然后插入到 <tbody />标签前。

          $(function() {
             $("#GriView1 tr:first").wrap("<thead></thead>");
             $("#GriView1 thead").insertBefore("#GriView1 tbody");
             $("#GriView1").tablesorter();
         });

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2021-05-28
  • 2021-06-09
  • 2021-11-20
  • 2022-12-23
猜你喜欢
  • 2021-06-05
  • 2022-12-23
  • 2022-01-18
  • 2021-04-08
  • 2021-06-25
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案