2016-01-24 63 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

相关问题