2012-07-24 69 views
3

我有一個表,其中tablesorter plugin添加到它。我已啓用filter widgetpager pluginjQuery Tablesorter過濾器沒有更新尋呼機

我遇到的問題是,當一個值放入過濾器輸入時,它不會更新尋呼機(總的結果,如果更多,然後頁面設置的頁數)。
此外,它似乎只過濾分頁結果,而不是整個表格。

是否有可能使其以這種方式工作?
我已經看過文檔,看不到如何做到這一點(也是我的JS不是那麼好)。

任何和所有的幫助表示讚賞。

我的tablesorter設置:

var pagerOptions = { 

      // target the pager markup - see the HTML block below 
      container: $(".pager"), 

      // output string - default is '{page}/{totalPages}'; possible variables: {page}, {totalPages}, {startRow}, {endRow} and {totalRows} 
      output: '{startRow} to {endRow} ({totalRows})', 

      // apply disabled classname to the pager arrows when the rows at either extreme is visible - default is true 
      updateArrows: true, 

      // starting page of the pager (zero based index) 
      page: 0, 

      // Number of visible rows - default is 10 
      size: 10, 

      // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty 
      // table row set to a height to compensate; default is false 
      fixedHeight: true, 

      // remove rows from the table to speed up the sort of large tables. 
      // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled. 
      removeRows: true, 

      // css class names of pager arrows 
      cssNext: '.next', // next page arrow 
      cssPrev: '.prev', // previous page arrow 
      cssFirst: '.first', // go to first page arrow 
      cssLast: '.last', // go to last page arrow 
      cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed 
      cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option 

      // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) 
      cssDisabled: 'disabled' // Note there is no period "." in front of this class name 

     }; 

     $.tablesorter.addParser({ 
      id: "datetime", 
      is: function(s) { 
       return false; 
      }, 
      format: function(s,table, cell) { 
       s = s.replace(/\-/g,"/"); 
       s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); 
       return $.tablesorter.formatFloat(new Date(s).getTime()); 
      }, 
      type: "numeric" 
     }); 

     $("#results").tablesorter({ 

     // initialize zebra striping and filter widgets 
     widgets: ["zebra", "filter"], 

     // headers: { 5: { sorter: false, filter: false } }, 

     widgetOptions : { 

      // css class applied to the table row containing the filters & the inputs within that row 
      filter_cssFilter : 'tablesorter-filter', 

      // If there are child rows in the table (rows with class name from "cssChildRow" option) 
      // and this option is true and a match is found anywhere in the child row, then it will make that row 
      // visible; default is false 
      filter_childRows : true, 

      // Set this option to true to use the filter to find text from the start of the column 
      // So typing in "a" will find "albert" but not "frank", both have a's; default is false 
      filter_startsWith : false, 

      // Set this option to false to make the searches case sensitive 
      filter_ignoreCase : true, 

      // Delay in milliseconds before the filter widget starts searching; This option prevents searching for 
      // every character while typing and should make searching large tables faster. 
      filter_searchDelay : 300, 

      // See the filter widget advanced demo on how to use these special functions 
      filter_functions : { 
          4 : function(e, n, f, i) { 
           alert(e); 
           console.log(e); 
           if (e != "") { 
            return e === f; 
           } 
          } 
         }, 

         empty: 'bottom', 

         dateFormat : "ddmmyyyy" 

     }, 
       widthFixed: true 
    }) 
     .tablesorterPager(pagerOptions) 

     // bind to pager events 
     // ********************* 
     .bind('pagerChange pagerComplete', function(e,c){ 
      console.log(e); 
      console.log(c); 

     var msg = '" event triggered, ' + (e.type === 'pagerChange' ? 'going to' : 'now on') + 
      ' page ' + (c.page + 1) + '/' + c.totalPages; 
     $('#display') 
      .append('<li>"' + e.type + msg + '</li>') 
      .find('li:first').remove(); 
     }); 
+0

大聲笑我今天也有一些與tablesorter的問題。 ':)' – 2012-07-24 22:23:56

+0

@CG我希望你能設法解決你的問題,這是在殺我。 – Rooneyl 2012-07-24 22:26:29

+1

過濾器小部件和傳呼機插件目前並不兼容。我正在爲它進行下一次更新,但同時嘗試使用這個過濾器小部件:https://github.com/jbritten/jquery-tablesorter-filter - 我認爲它適用於尋呼機插件 – Mottie 2012-07-26 23:52:51

回答

1

過濾器部件和尋呼機插件/插件現在要做的共同努力,但尋呼機removeRows option必須設置爲false。這個選項的作用是保留表格中的所有行,而不是僅將當前頁面(可見)行添加到DOM。

Bootstrap theme demo

在「不遠的將來」版本中,removeRows選項將不再作爲過濾器部件將在表中訪問存儲的緩存行,而不是行的要求。

+0

@Leonid,我會將此標記爲解決方案,因爲在這個時候是這樣。我相信Mottie會在「不遠的將來」適時回來並更新答案。 – Rooneyl 2014-03-25 09:31:49

+0

你好Mottie,這是否仍然是這個問題的最新解決方案? – 2016-07-21 02:20:41

+0

@JuanCarlosOropeza無論「removeRows」選項如何設置,filter&pager widget/addon都應該很好地協同工作。 – Mottie 2016-07-21 10:16:44