1

I am trying to use yadcf plugin for multiselect plugin in my datatable since it is flexible to use.It generates dropdown multiselect filter with values available in perticular row. I want to customize this in such a way to pass my own list and values corresponding to same like (list)but not getting how can i do this. If anyone could guide me in this, I will be grateful for you.

{    
    column_number: 1,
    filter_type: "multi_select",
    select_type: 'select2',
    filter_reset_button_text: false
}]);
Daniel
  • 36,833
  • 10
  • 119
  • 200
techhunter
  • 683
  • 1
  • 12
  • 27

1 Answers1

1

You should use the data property

For example

{    
    column_number: 1,
    filter_type: "multi_select",
    select_type: 'select2',
    filter_reset_button_text: false,
    data: ["value1","value2"]
}

Here is small fragment from the docs (you better read more in order to know about yadcf feature)

* data
                Required:           false
                Type:               Array (of string or objects)
                Description:        When the need of predefined data for filter is needed just use an array of strings ["value1","value2"....] (supported in select / multi_select / auto_complete filters) or
                                    array of objects [{value: 'Some Data 1', label: 'One'}, {value: 'Some Data 3', label: 'Three'}] (supported in select / multi_select filters)
                Note:               that when filter_type is custom_func / multi_select_custom_func this array will populate the custom filter select element
*
Daniel
  • 36,833
  • 10
  • 119
  • 200
  • Hi Daniel, Thanks for the response. I am trying to understand this. for ex: i want to create filter like the above means, it will be done as "data:[{ value:"a","b", label:'name'}]" . Am i right? – techhunter Nov 08 '16 at 05:44
  • Not sure how it will behave with `|` in the value (escaping / etc') start with value="a" and proceed from there – Daniel Nov 08 '16 at 07:54
  • 1
    This plugin is really good. Is there any way that I can pass more than one value for ex. something like data:[{value: ['Some Data 1','Some Data 2'], label: 'One'}] ? – techhunter Nov 09 '16 at 05:48
  • you can do something like this data:: [{value: ['Some Data'], label: 'Some Data'}], filter_match_mode: 'contains' , read docs - https://github.com/vedmack/yadcf/blob/3db921a674f785af22d436b2676e8bf04c07004a/src/jquery.dataTables.yadcf.js#L187 , you can also use regular expressions, try it and try googling this – Daniel Nov 09 '16 at 08:09
  • Thganks again. But i need to pass multiple values in value attribute. – techhunter Nov 09 '16 at 08:25
  • you can also use the `filter_type: 'custom_func',` or `multi_select_custom_func` see showcase http://yadcf-showcase.appspot.com/DOM_source.html (first column) , read docs for more info – Daniel Nov 09 '16 at 08:45