vedmack / yadcf

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

Maintain auto-populated list of filters when using multi_select_custom_func #178

Closed bdunsmuir closed 9 years ago

bdunsmuir commented 9 years ago

If you use the multi_select_custom_func to make a custom filter selector, the selection list is no longer populated with all the possible values for that column.

It would be nice to add a custom filter to the list, but still have the list populate with all the other possible values.

vedmack commented 9 years ago

You can use the append_data_to_table_data for that

bdunsmuir commented 9 years ago

Daniel, it doesn't appear to be working for me. I am only getting the values I put in the data array. Here is my code:

{column_number : hold_index,
        select_type:'select2',
        filter_type: "multi_select_custom_func",
        filter_match_mode: 'exact',
        custom_func: hold_code_filters,
        data: [   
          {value: 'Exclude On Hold', label: 'Exclude On Hold'},
          {value: 'On Hold Only', label: 'On Hold Only'},
        ],
        append_data_to_table_data: true,
        filter_default_label:'All'
        },
vedmack commented 9 years ago

Are you using the latest beta version? if yes, please provide a jsbin / jsfiddle

bdunsmuir commented 9 years ago

Is there an existing jsfiddle I can edit? I couldn't post all of what I have and I'm not really sure how to setup a jsfiddle with all of the required files.

I am using the new beta version. The new custom_func() is working well with rowValues

vedmack commented 9 years ago

You can modify the following jsbin

bdunsmuir commented 9 years ago

Not sure what I'm doing wrong here, but I can't get a jsbin to work at all. Maybe select2 is not available in jsbin. I'm a novice programmer.

http://jsbin.com/cuyirevufo/2/edit?js,output

vedmack commented 9 years ago

added fix to yadcf so grab the latest beta version and fixed your example

bdunsmuir commented 9 years ago

Still can't get it to work. I tried copying everything directly to my code and no luck. I made sure I am using the newest beta version. I am using ajax to populate my table, not sure if that makes a difference.

Everything else works and I get no error messages in the console. I assume it is just not seeing any existing values in my columns?

vedmack commented 9 years ago

Since it does work fine in the jsbin, I wont be able to help you more without a live sample with your issue

bdunsmuir commented 9 years ago

I've managed to make a live example that shows the problem. I think it must be something to do with the ajax.

I had to email you the ajax file as I wasn't sure how to host it on jsbin. Here is the JSBIN http://jsbin.com/weluwewafu/1/edit?html,js,output

bdunsmuir commented 9 years ago

I am getting a jquery error. Try this jsbin, I think I have correctly linked to the new beta release. http://jsbin.com/gikulu/1/edit?html,js,console,output

Also, is it possible to use the sort options to put the grouped selections at the top of the list? Like prepend them instead of append them?

I know this is a real PITA, but thank you for such a great plugin.

vedmack commented 9 years ago

it will take me some time to fix it properly for ajax too... I'll update this issue when I'll finish this one

vedmack commented 9 years ago

should work now, try the latest beta...

bdunsmuir commented 9 years ago

It is working now, thank you very much!

I tried using sort_order with this but it doesn't do anything. Will it be possible to select a sort order with this, or put the grouped selections at the top of the list? Would you prefer I open another ticket for that?

Once again, thank you for the work on this.

vedmack commented 9 years ago

No need for new issue, I'll abuse this one...

vedmack commented 9 years ago

updated, read updated docs if you want to add your data array before on top of the select use before , if you want it to appear sorted then at least for now you shouldn't use array with value/label but use an array of strings. for sorting array with value/label you should open a new issue and know that it will take some time to be added...

bdunsmuir commented 9 years ago

This works great, thank you .

peterjun-md commented 3 years ago

I'm having issues where I can get the myCustomFilterFunction cases working, but when trying to select any of the populated values in that column, it doesn't filter and displays all rows. Also when selecting multiple myCustomFilterFunction cases or a myCustomFilterFunction case and a populated value, I get no rows returned.

Used code from here https://stackoverflow.com/questions/34089173/yadcf-apply-and-filterring-to-multiple-selections-from-a-json-array