0
我使用jQuery數據表,我想篩選基於數據表與篩選下拉列表
與下拉列表中的數據表昨天
最後7天
過去15天
過去30天
過濾,應根據國家時間列即列中沒有3 表的內容如下:
Host Name Severity State Time
localhost Warning 2017-02-10 10:19:38
localhost Warning 2017-02-18 15:59:24
localhost critical 2017-02-25 02:29:34
localhost critical 2017-02-27 15:57:24
localhost Warning 2017-02-27 09:20:15
localhost critical 2017-03-16 03:30:50
localhost ok 2017-03-17 09:20:35
localhost ok 2017-03-17 10:20:47
JS代碼:
criticalEventTableList1 = $('#example2').dataTable({
data: historyEventList.seriesCriticalEventList1,
"paging": false,
dom: 'Bfrtip',
buttons: [
'csv', 'excel'
],
"iDisplayLength": 10,
"bFilter": true,
"paging": true,
"responsive": true,
"createdRow": function(row, data, index ) {
if (data[2] == "1")
{
$('td', row).eq(2).css('background-color', '#FFC300','font-weight', 'bold');
$('td:eq(2)', row).html('<b>Warning</b>');
}
else if (data[2] == "2")
{
$('td', row).eq(2).css('background-color', '#F13B3B','font-weight', 'bold');
$('td:eq(2)', row).html('<b>Critical</b>');
}
},
});
HTML代碼:
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">Select
<span class="caret"></span></button>
<ul class="dropdown-menu" role="menu" aria-labelledby="menu1">
<li role="presentation"><a role="menuitem" tabindex="-1" id="" >Yesterdays</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" id="" >Last 7 Days</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" id="" >Last 15 Days</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" id="" >Last 1 Month</a></li>
</ul>
您需要至少說明你的js代碼的數據表。 –
嗨亞瑟我已經添加了我的js代碼 – Gauravkb
@Gauravkb這個怎麼樣? https://jsbin.com/pahojutuse/edit?html,js,output – bassxzero