Currently I'm working on Datatable. I am trying to create a dropdown filter. But as I am using fetching data from db, in the option field there will be multiple values. is it possible to match array of values on clicking selecting a particular item from list?
For example consider the code below.
$('#mySelect').on('change',function(){
var selectedValue = $(this).val();
table.fnFilter("^"+selectedValue+"$", 0, true); //Exact value, column, reg
});
select: <select id="mySelect">
<option value="">All</option>
<option value="array1">a</option>
<option value="array2">saf</option>
</select>
and actual scenario here.
- I have a drop down list of vendor.
- I will fetch the items corresponding to each vendor from db table.
- Each vendor may have more than one item.
- Upon selecting the vendor name from the list, it has to filter corresponding items from Datatable.
so, <option value="item_code">vendor_name</option>
it's ok if only one item exist for the particular vendor. What if multiple items present? So i thought to store item_codes
in an array and pass it value for filter. But how to make it works?
Or any other alternate ideas will be appreciated.