2016-01-24 64 views
1

我正在使用PHP預加載我的表,然後在我的配置中有processAjaxOnInit:false。會發生什麼是對我的Ajax url的調用仍在進行,而不是將行附加到表中,它會清除那些行。我假設它仍在撥打電話以獲取總行數。我可以在頁面加載時設置它,完全繞過調用Ajax url嗎?processAjaxOnInit:設置爲「false」,但仍然調用Ajax

感謝

.tablesorterPager({ 

    container: $(".pager"), 

    ajaxUrl : '/documents_table_data.php?page={page}&size={size}&{filterList:filter}&{sortList:column}', 

    // use this option to manipulate and/or add additional parameters to the ajax url 
    customAjaxUrl: function(table, url) { 
    // manipulate the url string as you desire 
    //url += '&archive=<?php echo $_GET[archive] ?>&wor=<?php echo $_GET[wor] ?>'; 

    // trigger a custom event; if you want 
    $(table).trigger('changingUrl', url); 
    // send the server the current page 
    return url; 
    }, 
    ajaxError: null, 
    ajaxObject: { 
    dataType: 'json' 
    }, 
    ajaxProcessing: function(data){ 
    if (data && data.hasOwnProperty('rows')) { 
     var r, row, c, d = data.rows, 
     total = data.total_rows, 
     headers = data.headers, 
     rows = [], 
     len = d.length; 
     for (r=0; r < len; r++) { 
     row = []; 
     for (c in d[r]) { 
      if (typeof(c) === "string") { 
      row.push(d[r][c]); 
      } 
     } 
     // is there a way to do that here when it pushes the row onto the array 
     // or perhaps there is another funtion you have implemented that will let me do that 
     rows.push(row); 
     } 
     return [ total, rows, headers ]; 
    } 
    }, 

    // Set this option to false if your table data is preloaded into the table, but you are still using ajax 
    processAjaxOnInit: false, 
    output: '{startRow} to {endRow} ({totalRows})', 
    updateArrows: true, 
    page: 0, 
    size: 10, 
    savePages: true, 
    storageKey: 'tablesorter-pager', 
    pageReset: 0, 
    fixedHeight: false, 
    removeRows: false, 
    countChildRows: false, 

    // 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 
    cssGoto  : '.gotoPage', // page select dropdown - select dropdown that set the "page" option 

    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; see the "updateArrows" option 
    // (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 
    cssErrorRow : 'tablesorter-errorRow' // error information row 

}); 

回答

0

我只是添加了一個名爲initialRows(目前僅在主分支提供)尋呼機選項。當processAjaxOnInitfalse這個選項設置,沒有初始AJAX調用服務器完成(demo):

$(function(){ 
    $('table').tablesorter({ 
    widgets: ['pager'], 
    widgetOptions : { 
     pager_processAjaxOnInit: false, 
     pager_initialRows: { 
     // these are both set to 50 initially 
     // the server can return different values 
     // and the output will update automatically 
     total: 50, 
     filtered: 50 
     }, 
     // other ajax settings... 
    } 
    }); 
}); 
+0

太謝謝你了! – phpmaven

相關問題