1
我正在使用jQuery表排序插件。jquery - 基於所有列的屬性排序
表列是基於sql查詢生成的。
如何根據屬性值對(asc和desc)進行排序。
注意:我不想像下面的代碼,因爲表列是生成多個(有時50列),所以我需要基於相同的屬性名稱對所有列進行排序。
$.tablesorter.addParser({
// set a unique id
id: 'myParser',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s, table, cell, cellIndex) {
// get data attributes from $(cell).attr('data-something');
// check specific column using cellIndex
return $(cell).attr('data-something');
},
// set type, either numeric or text
type: 'text'
});
你好,在我的情況下,表列是基於查詢(mysql數據庫)生成的。所以,我認爲這種方法不適合我的情況。 http://mottie.github.io/tablesorter/docs/example-option-text-extraction.html – RSKMR