Created
November 5, 2019 18:20
-
-
Save XDavidT/02977d26b856478ada936c29bb7ca125 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//rules table// | |
$.getJSON('/api/policy/data2table',function(data){ | |
$(document).ready(function() { | |
var table = $('#RuleDataTable').DataTable({ | |
orderCellsTop: true, | |
fixedHeader: true, | |
data:data, | |
"pageLength": 5, | |
columns: [ | |
{data: '_id'}, | |
{data: 'name'}, | |
{data: 'field'}, | |
{data: 'value'} | |
] | |
}); | |
$('#RuleDataTable tbody').on('click','tr',function(e){ | |
e.preventDefault() | |
var data = table.row( this ).data() | |
console.log(data._id) | |
}) | |
}); | |
}) | |
//event table/// | |
$.getJSON('/api/policy/eventData2table',function(data){ | |
$(document).ready(function() { | |
var table = $('.eventDataTable').DataTable({ | |
orderCellsTop: true, | |
fixedHeader: true, | |
data:data, | |
"pageLength": 5, | |
columns: [ | |
{data: '_id'}, | |
{data: 'name'}, | |
{data: 'description'}, | |
{data: 'type'}, | |
{data: 'full.rules.rule_id', | |
render: function ( full, type, full, meta ) { | |
var result = ''; | |
$.each(full.rules, function( index, value ) { | |
result_temp = value.rule_id; | |
if (index < full.rules.length) | |
result = result + result_temp + ', ' ; | |
}); | |
return result.split(", ").join("<br/>"); | |
}, | |
"className": "text-center" | |
}, | |
{data: 'full.rules.repeated', | |
render: function ( full, type, full, meta ) { | |
var result = ''; | |
$.each(full.rules, function( index, value ) { | |
result_temp = value.repeated; | |
if (index < full.rules.length) | |
result = result + result_temp + ', ' ; | |
}); | |
return result.split(", ").join("<br/>"); | |
}, | |
"className": "text-center" | |
}, | |
{data: 'full.rules.timeout', | |
render: function ( full, type, full, meta ) { | |
var result = ''; | |
$.each(full.rules, function( index, value ) { | |
result_temp = value.timeout; | |
if (index < full.rules.length) | |
result = result + result_temp + ', ' ; | |
}); | |
return result.split(", ").join("<br/>"); | |
}, | |
"className": "text-center" | |
} | |
] | |
}); | |
}); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment