모든 filter_serversideFiltering
옵션은 호출기 위젯/addon과의 통합을 허용하고 내용이 일치하지 않으면 테이블의 행을 숨기는 것을 방지합니다.
호출기 위젯/추가 기능이 없으면 filterEnd
이벤트에 바인딩하고 자신의 아약스 호출을 수행해야합니다. Here is a demo filltext.com을 사용하여 JSON 데이터를 제공하므로 결과가 필터와 일치하지 않지만 필터링 후에 업데이트 된 것을 확인할 수 있습니다. 콘솔 네트워크 탭에서 사용중인 실제 URL을 볼 수 있습니다.
HTML
<table class="tablesorter">
<thead>
<tr>
<th>#</th>
<th>ID</th>
<th>First</th>
<th>Last</th>
<th>State</th>
<th>Info</th>
</tr>
</thead>
<tbody></tbody>
</table>
스크립트
$(function() {
var $table = $('table'),
lastSearch = [],
updateAjax = function (filters) {
$.getJSON('http://www.filltext.com/?callback=?', {
// add the current filters to be serialized
// into a URL query string
// commented out here or filltext.com returns nothing
// 'filter': filters
// the following parameters are needed for
// filltext.com to return content
'rows': 10,
'#': '{index}',
'ID': '{randomNumberLength|3}',
'First': '{firstName}',
'Last': '{lastName}',
'State': '{usState|abbr}',
'Info': '{lorem|3}'
})
.done(function (data) {
buildTable(data);
});
},
buildTable = function (data) {
if (data) {
var col, row, txt,
headers = ['#', 'ID', 'First', 'Last', 'State', 'Info'],
len = headers.length,
rows = '';
size = data.length;
for (row = 0; row < size; row++) {
rows += '<tr>';
for (col = 0; col < len; col++) {
txt = data[row][headers[col]];
rows += '<td>' + txt + '</td>';
}
rows += '</tr>';
}
$table.find('tbody')
.html(rows)
.trigger('update');
}
};
$table.on('filterEnd', function (e, c) {
// prevent ajax spamming
var ls = c.$table.data('lastSearch');
if (lastSearch.join('-') !== ls.join('-')) {
lastSearch = ls;
updateAjax(lastSearch);
}
})
.tablesorter({
theme: 'blue',
widthFixed: true,
widgets: ['zebra', 'filter'],
widgetOptions: {
// prevents rows from getting hidden
filter_serversideFiltering: true
}
});
});
이 내가 찾을 수있는 모든 것입니다 : http://aplia.com/media/jsframeworks/jquery/plugins/tablesorter/docs/example-widget- filter.html 필자는 아마도 필 터를 필터로 설정하고, 콘솔을 열고, 어떤 헤더를 보냈는지 확인해야 할 것입니다. – DevlshOne
@DevlshOne이 페이지는 이전 버전의 tablesorter 포크에 대한 문서를 가지고 있습니다. 다음은 [현재 필터 문서 페이지] (http://mottie.github.io/tablesorter/docs/example-widget-filter.html)입니다. – Mottie