Show no record found using tablesorter search widget

本秂侑毒 提交于 2020-01-04 06:25:11

问题


I am using "jquery.tablesorter.widgets.js" for Table filter working fine, but I have to display " No Data Found" when records not available based on Search Criteria. I'm not using any pager on my table. i have checked this link TableFilter Plugin with Null Data but unable to resolve my problem.


回答1:


Without the pager you'll need to create a message row yourself (demo):

CSS

tr.noData td {
  background: #eee;
  color: #900;
  text-align: center;
}

JS

$('table').on('filterEnd filterReset', function() {
  var c = this.config,
    fr = c.filteredRows;
  if (fr === 0) {
    c.$table.append([
      // "remove-me" class added to rows that are not to be included 
      // in the cache when updating
      '<tr class="noData remove-me" role="alert" aria-live="assertive">',
        '<td colspan="' + c.columns + '">No Data Found</td>',
      '</tr>'
    ].join(''));
  } else {
    c.$table.find('.noData').remove();
  }
});


来源:https://stackoverflow.com/questions/34505689/show-no-record-found-using-tablesorter-search-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!