1
我在jQuery數據表格中添加了下拉選擇。JQuery數據表列的自定義排序下拉列表
table.columns().every(function() {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo($(column.footer()).empty())
.on('change', function() {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search(val ? '^' + val + '$' : '', true, false)
.draw();
});
column.data().unique().sort().each(function(value, j) {
select.append('<option value="' + value + '">' + value + '</option>')
});
});
以下是完整的源代碼 plunker link。
當我打開下拉列表的值被排序爲String而不是整數。 例如,下面的下拉列表中給出了選擇
[1,10,11,2,...] && [Item 1,Item 10,Item 11,...]
我想回答的
[1,2,3,4,..10,11..] && [Item 1,Item 2,Item 3,...]