0

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.

  1. I have a drop down list of vendor.
  2. I will fetch the items corresponding to each vendor from db table.
  3. Each vendor may have more than one item.
  4. 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.

Mamdouh Saeed
  • 2,302
  • 1
  • 9
  • 11
techhunter
  • 683
  • 1
  • 12
  • 27

0 Answers0