Multiple select filtering
Multiple select filtering
I'm using a query multiple select (http://wenzhixin.net.cn/p/multiple-select/) and trying to filter with multiple option.
I want to filter multiple words in one column. if there's words "dog" or "cat" in a column, i want the result to be rows with "dog" or "cat" in the column. how can I implement this? thanks.
I want to filter multiple words in one column. if there's words "dog" or "cat" in a column, i want the result to be rows with "dog" or "cat" in the column. how can I implement this? thanks.
This discussion has been closed.
Replies
Allan
oInvestmentsTable.fnFilter(filter, 6, true, false);
where if two options 'A' and 'B' are selected in multi-select my filter will be "A|B"
the table below
[code]
var oInvestmentsTable = $('#'+investmentTableId).dataTable({
"aaSorting": [[ sortColumn, order ]],
"sAjaxSource": ajaxUrl + ".html",
"aoColumns": [
{ "sTitle": "Offering Id" }, { "sTitle": "Offering Name"},
{ "sTitle": "Created User" }, { "sTitle": "Contact Phone" },
{ "sTitle": "Contact Email" },
{ "sTitle": "Asset Sponsor Id" }, { "sTitle": "Offering Type" },
{ "sTitle": "Status Create" }, { "sTitle": "Status Admin Review" },
{ "sTitle": "Status IC Review" }, { "sTitle": "Status Funding" },
{ "sTitle": "company.companyName" }, { "sTitle": "companyId" },
{ "sTitle": "Start Date" }, { "sTitle": "NDA Waived" },
{ "sTitle": "Banker Read" }, { "sTitle": "Issuer Read" },
{ "sTitle": "Accredited Investor Read" }, { "sTitle": "Institutional Investor Read" },
{ "sTitle": "Vertical Name" }
],
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
if(addDeleteButton && ($(nRow).find('.delete-icon').length == 0) ) {
var deleteIcon = $("").addClass("ui-icon ui-icon-trash");
$("").addClass("delete-icon").appendTo(nRow).html(deleteIcon);
}
if($('td:eq(1)', nRow).html() == "") {
$('td:eq(1)', nRow).html("Pending Review");
//$('td:eq(1)', nRow).css("background", "#A3C2FF");
}
else if($('td:eq(1)', nRow).html() == "ai") {
$('td:eq(1)', nRow).html("Addl. Info. Reqd.");
}
return nRow;
},
"aoColumnDefs": [
{"bVisible": false, "aTargets": [0]},
{"bVisible": false, "aTargets": [2]},
{"bVisible": false, "aTargets": [3]},
{"bVisible": false, "aTargets": [4]},
{"bVisible": false, "aTargets": [5]},
{"bVisible": false, "aTargets": [7]},
{"bVisible": false, "aTargets": [8]},
{"bVisible": false, "aTargets": [9]},
{"bVisible": false, "aTargets": [10]},
{"bVisible": false, "aTargets": [11]},
{"bVisible": false, "aTargets": [12]},
{"bVisible": false, "aTargets": [13]},
{"bVisible": false, "aTargets": [14]},
{"bVisible": false, "aTargets": [15]},
{"bVisible": false, "aTargets": [16]},
{"bVisible": false, "aTargets": [17]},
{"bVisible": false, "aTargets": [18]}
],
"bPaginate": false,
"bScrollInfinite": true,
"bScrollCollapse": true,
"iDisplayLength" : 100,
"sDom": 't'
});
[/code]
but i tried the same way in the table below but it's not giving any result.
[code]
oUserTable = $('#user-table').dataTable(
{
"sAjaxSource" : "loadUserTable.html",
"bServerSide" : true,
"bProcessing": true,
"aaSorting" : [ [ 1, "asc" ] ],
"sScrollY": "280px",
"sScrollX": "100%",
"sPaginationType" : "full_numbers",
"sDom" : '<"top"l>rt<"bottom"ip>',
"aoColumns":[
{"mData":"login","sWidth" : "200px"},
{"mData":"firstName","sWidth" : "115px"},
{"mData":"lastName","sWidth" : "115px"},
{"mData":"userType","sWidth" : "130px"},
{"mData":"company","sWidth" : "150px", "bSortable": false},
{"mData":"country.countryName","sWidth" : "100px","bVisible" : false},
{"mData":"referredBy","sWidth" : "100px","bVisible":false}
],
});
[/code]
is there anything else I should add for the rejex to work?
This means that the filtering is done entirely by the server-side script (loadUserTable.html in this case). So if you want to provide regular expression filtering abilities in that script, you would need to add that into your script.
Allan
one more doubt, what's the maximum length we can give to the regex expression?
i'm using it for multi-select filtering. so my expression with '|' when just one option is unselected is about 810 characters length. and it doesnt work. but then i select 3-4 options in multiselect it works. So is there a maximum length for the 'filter' regex in fnFilter? thanks.
DataTables places no limit on the length of the inputs. What might be happening, if you are using server-side processing still, is that the GET request is being rejected by the server. Your server's error logs would tell you if this is the case.
Allan