I'm loading data via Ajax, but I cannot get MultiSelect filtering to work!
I'm loading data via Ajax, but I cannot get MultiSelect filtering to work!
Phiph
Posts: 2Questions: 1Answers: 0
Hi All,
I am currently loading my data with ajax, which works fine! However I would like MultiSelect filtering on my table, but it just doesn't want to work! I am using ASP MVC hence the @Url.Action
The result only renders 1 select box, which is empty.
Any help would be greatly appreciated.
$('#GetAllCustomers').click(function() {
$.get("/Reports/Table").done(function (result) {
$("#divResult").html(result);
table = $('#example').dataTable({
destroy: true,
"processing":true,
"serverside": true,
"ajax": {
"url": "@(Url.Action("GetAllCustomers", "Reports"))",
"type": "POST",
"dataType": "json",
"dataSrc": ""
},
"columns": [
{
"title": "Account Number",
"data": "AccNumber"
},
{ "title": "account Number", "data": "CustomerAccountName" }
],
"stateSave": true,
"dom": "<'row'<'col-xs-4'l><'col-xs-4 center'T><'col-xs-4'f>r>"
+ "t" +
"<'row'<'col-xs-6'i><'col-xs-6'p>>",
"tableTools": {
"sSwfPath": "\/assets/DataTables/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"oSelectorOpts": { filter: 'applied', order: 'current' }
},
{
"sExtends": "xls",
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "pdf",
"oSelectorOpts": { filter: 'applied', order: 'current' },
"sFileName": "AccountList",
"sPdfOrientation": "landscape",
},
{
"sExtends": "print",
"oSelectorOpts": { filter: 'applied', order: 'current' },
}
]
}
});
$("#example tfoot th").each(function (i) {
var select = $('<select><option value=""></option></select>')
.appendTo($(this).empty())
.on('change', function () {
table.column(i)
.search($(this).val())
.draw();
});
table.column(i).data().unique().sort().each(function (d, j) {
select.append('<option value="' + d + '">' + d + '</option>')
});
});
});
});
This discussion has been closed.