我最近添加的tablesorter插件的叉GitHub上所有的丟失選項和更多示例的列表。我不確定您是否只想在標題中添加圖標或更改排序方向箭頭。如果您想添加圖標,請使用onRenderHeader
函數將您想要的任何內容添加到標題。這是一個example。
如果您想更改排序方向箭頭,請繼續閱讀!我不確定要添加哪個箭頭圖標,但是我只是使用粗箭頭圖標將這個小部件放置在tablesorter(我將盡快添加示例頁面到文檔)。如果您想使用不同的圖標集,請查看this page上的圖標,並將鼠標懸停在圖標上,然後在下面的窗口小部件代碼中修改icons
變量,以將圖標選擇。圖標順序是向上/向下箭頭,向下箭頭和向上箭頭。
這裏是a demo和代碼:
$(function() {
// add ui theme widget
$.tablesorter.addWidget({
id: "uitheme",
format: function(table) {
var c = table.config,
// *** Modify the theme icons here ***
// ["up/down arrow (cssHeaders, unsorted)", "down arrow (cssDesc, descending)", "up arrow (cssAsc, ascending)" ]
icons = ["ui-icon-arrowthick-2-n-s", "ui-icon-arrowthick-1-s", "ui-icon-arrowthick-1-n"],
klass, rmv = icons.join(' ');
if (!$(c.headerList[0]).is('.ui-theme')) {
$(table).addClass('ui-widget ui-widget-content ui-corner-all');
$.each(c.headerList, function(){
$(this)
// using new "ui-theme" class in case the user adds their own ui-icon using onRenderHeader
.addClass('ui-state-default ui-corner-all ui-theme')
.append('<span class="ui-icon ui-theme"/>');
});
}
$.each(c.headerList, function(){
klass = ($(this).is('.' + c.cssAsc)) ? icons[1] : ($(this).is('.' + c.cssDesc)) ? icons[2] : icons[0];
$(this).find('span.ui-theme').removeClass(rmv).addClass(klass);
});
}
});
// call the tablesorter plugin and apply the ui theme widget
$("table").tablesorter({
widgets : ['uitheme']
});
});
您還需要改爲使用這個CSS藍色/綠色主題
/* jQuery UI Theme */
table.tablesorter {
font-family: arial;
margin: 10px 0pt 15px;
font-size: 8pt;
width: 100%;
text-align: left;
}
table.tablesorter thead tr th, table.tablesorter tfoot tr th {
border-collapse: collapse;
font-size: 8pt;
padding: 4px;
}
table.tablesorter thead tr .header {
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
table.tablesorter tbody td {
padding: 4px;
vertical-align: top;
}
table.tablesorter .header .ui-theme {
display: block;
float: right;
}
我只是想補充一點,這個主題看起來更好如果你在上面的javascript中用'ui-widget-header'替換'ui-state-default'。 – Mottie