使用tablesorter搜索小部件显示未找到的记录

时间:2015-12-29 06:31:00

标签: jquery tablesorter

我使用“jquery.tablesorter.widgets.js”表格过滤器工作正常,但是当基于搜索条件的记录不可用时,我必须显示“找不到数据”。我在桌子上没有使用任何寻呼机。我已检查此链接TableFilter Plugin with Null Data但无法解决我的问题。

1 个答案:

答案 0 :(得分:2)

如果没有寻呼机,您需要自己创建一个消息行(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();
  }
});
相关问题