本文介绍了与jQuery表分拣机在同一页上的问题2的Gri​​dView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待实现的JQuery表分拣机2格的观点,这是在同一页上。但是,我们我试图通过编写单独的函数来实现,它不能正常工作。可有一个人,请帮助我。

I'm looking to implement JQuery Table Sorter for 2 grid-views, which are on the same page. But we i'm trying to implement by writing separate functions, it is not working properly. Can some one please assist me.

有关的GridView 1:

For Gridview 1:

function SortOrderBooks() {
            var gwHeader = document.getElementById("dummyTable");

                var gwheaders = gwHeader.getElementsByTagName("TH");

                gwheaders[6].setAttribute("onclick", "SortBooks(this, 1)");
                gwheaders[6].onclick = function () { SortBooks(this, 1); };
                gwheaders[6].className = "sortDesc";



        }

        function SortBooks(cell, sortOrder) {

            var sorting = [[cell.cellIndex, sortOrder]];
            $("#<%=gvResults.ClientID%>").trigger("sorton", [sorting]);
            if (sortOrder == 0) {

                sortOrder = 1;
                cell.className = "sortDesc";
            }
            else {

                sortOrder = 0;
                cell.className = "sortAsc";

            }

            cell.setAttribute("onclick", "SortBooks(this, " + sortOrder + ")");
            cell.onclick = function () { SortBooks(this, sortOrder); };

        }

2的Gri​​dView:

GridView 2:

 function SortedTables() {
            var gvHeader = document.getElementById("dummyHeader");

            var headers = gvHeader.getElementsByTagName("TH");

            headers[2].setAttribute("onclick", "Sort(this, 1)");
            headers[2].onclick = function () { Sort(this, 1); };
            headers[2].className = "sortDesc";

       }
       function Sort(cell, sortOrder) {

            var sorting = [[cell.cellIndex, sortOrder]];
            $("#<%=gvTableResults.ClientID%>").trigger("sorton", [sorting]);
            if (sortOrder == 0) {
                sortOrder = 1;
                cell.className = "sortDesc";
            }
            else {
                debugger;
                sortOrder = 0;
                cell.className = "sortAsc";
            }

            cell.setAttribute("onclick", "Sort(this, " + sortOrder + ")");
            cell.onclick = function () { Sort(this, sortOrder); };

        }

这不是GridView的工作1,可以有人请帮助我如何解决这个请。

It is not working for GridView 1, can someone please assist me how to solve this one please.

推荐答案

这是联正在用一个固定的头一个表......我开始认为这可能只是使用标识的问题。本教程

The tutorial that was linked is making a table with a fixed header... I'm starting to think that it might just be an issue with IDs.

我想你可能会更好,没有任何额外的code的。

I think you might be better off without any of that extra code.


  • 删除虚拟头

  • 摆脱多余的CSS

  • 摆脱额外的JavaScript

所有你应该需要的是加载了jQuery,主题的tablesorter,&的tablesorter放大器;的tablesorter部件。

All you should need is to load jQuery, tablesorter theme, tablesorter & tablesorter widgets.

<link href="../css/theme.blue.css" rel="stylesheet">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.tablesorter.js"></script>
<script src="../js/jquery.tablesorter.widgets.js"></script>

然后初始化的tablesorter两个表:

Then initialize tablesorter on both tables:

$(function(){

  $("#<%=GridView1.ClientID%>, #<%=GridView2.ClientID%>").tablesorter({
    theme : "blue",
    widgets : [ 'zebra', 'stickyHeaders' ]
  });

});

这篇关于与jQuery表分拣机在同一页上的问题2的Gri​​dView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 11:25