vedmack / yadcf

Yet Another DataTables Column Filter (yadcf)
http://yadcf-showcase.appspot.com/
MIT License
732 stars 284 forks source link

Is it possible to populate an external filter with JSON #556

Closed pcapp2114 closed 5 years ago

pcapp2114 commented 5 years ago

I am using Datatables and Yadf for external filters. I have a list of 400 terms that I want to load into the external filter. The list is in JSON format. Can I create a Yadf custom_func that populates an external_filter_container with JSON from a URL source or from a JSON file? The JSON is in this format. I know it will be a really long select list. {"id":"1","text":"Team A"},{"id":"1","text":"Team B"} Or can the filter load a flat text list of values? we cannot use the data from from the column because it is in a coma separated list example Team A,Team B,Team C.

vedmack commented 5 years ago

You have several options, use select2 with its own data fetching from url (read yadcf docs / some google / etc) there were some previous questions of users that tried it, you can populate any filter with the data property <-- read about it

p.s

next time please ask question on SO

pcapp2114 commented 5 years ago

Thank you @vedmack. We are currently using the custom_func and data method to populate some smaller filters. And a teammate was able to get select2 to load a JSON url source but it required many changes and removing yadf to do it. I like the simplicity of yadf alone.

vedmack commented 5 years ago

well I can add the ability to specify a URL to load the filters from for yadcf and it will be called on init, please specify a scenario or usage example of such functionality and I'll try to see what can be done

pcapp2114 commented 5 years ago

Is it possible to mix the two. So that some filters will use Yadf and others will use the select2 JSON source?

vedmack commented 5 years ago

@pcapp2114 should be possible (that what I meant by saying "use select2 with its own data fetching from url") try using the select_type_options for that purpose, I recall some users posted their code with select2 and fetching data by specifying in select_type_options (dont remember if it worked for them but it worth checking, let me know how it went for you