2013-07-29 27 views
1

我使用的是桌面jquery插件,我遇到了一点麻烦。jQuery TableSort插件

我有一个表有10列,我有一个过滤器,如果我解开一个盒子,使用CSS display:none从表中删除相关的列。

这一切工作正常,但是当我然后使用分页时,这些细节然后显示。

看来,表分拣机插件relaods表数据并显示所有行,即使它们被设置为display:none

是否存在,如果这些列未显示/隐藏的方式,那么当寻呼触发这些不显示?

感谢

编辑:

$("#searchContainer #toggleOptions ul li a").on(

      {click: function() 

        { 

         //detect classes 
         var currentButtonCnt = $(this).parent().attr("class"); 
         var currentState = $(this).attr("class"); 

         //remove _btn 
         currentButton = "."+currentButtonCnt.substr(0, currentButtonCnt.length-4); 

         var ids = []; 
         //toggle 
         if(currentState == "ticked"){ 

           $(currentButton).hide(); 
           $(this).removeClass('ticked') 

         }else{ 

           $(currentButton).show(); 
           $(this).addClass('ticked') 

         } 

       } 

      }//end click 

    ) 

回答

0

它看起来像的tablesorter寻呼机插件交换每次切换页面的每一行/列的时间<td>元素。我猜你的display:none风格只适用于你想要隐藏的当前显示的<td>,所以无论何时翻到下一页,新的<td>都会翻转,并且不受display:none功能的影响。

假设你的函数通过你的<table>循环和发现的<td>右列取决于其checkbox被选中,你应该能够解决您的问题,通过调用你的函数隐藏相应的列on click单击每次隐藏寻呼机下一个以前的按钮。

编辑:

您可以在下一步和上一个按钮,选择添加到您的功能如下:

//Add .next and .prev selectors here to your click function 
$("#searchContainer #toggleOptions ul li a, .next, .prev").on(

      {click: function() 

        { 

         //detect classes 
         var currentButtonCnt = $(this).parent().attr("class"); 
         var currentState = $(this).attr("class"); 

         //remove _btn 
         currentButton = "."+currentButtonCnt.substr(0, currentButtonCnt.length-4); 

         var ids = []; 
         //toggle 
         if(currentState == "ticked"){ 

           $(currentButton).hide(); 
           $(this).removeClass('ticked') 

         }else{ 

           $(currentButton).show(); 
           $(this).addClass('ticked') 

         } 

       } 

      }//end click 

    ) 

它看起来像的tablesorter页面插件默认的类.next.prev。检查这里:http://tablesorter.com/docs/example-pager.html并检查按钮元素。

+0

我已经修改我的问题与执行删除列的代码。我不知道如何将代码添加到下一个/上一个按钮 –

+0

已更新的答案。 – projeqht

+0

嗨。感谢那。我现在遇到的问题是,在控制台中出现以下错误:'TypeError:currentButtonCnt is undefined' –