2013-07-29 26 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' –