yadcf column filter double match "100%" also returns "1000%" items

yadcf column filter double match "100%" also returns "1000%" items

organizerorganizer Posts: 7Questions: 1Answers: 0
edited January 2015 in Free community support

Hi all, I hope someone can help. I'm running the latest datatables and a custom filter dropdown yadcf on a column. This filter has several percent values option e.g. 50%, 100% 200% and 1000% which matches data in that column. My problem is when I select 100% from my dropdown it also matches/returns all 1000% rows on my result (running this as ajax/server-side).

Any smart way of resolving this?

This is myyadcf init.

{
            filter_container_id: "format_filter",
            column_number: 3,
            data: [
                { value: '50%', label: '50%' }, 
                { value: '70%', label: '70%' }, 
                { value: '100%',label: '100%' }, 
                { value: '200%', label: '200%' }, 
                { value: '400%', label: '400%' }, 
                { value: '1000%', label: '1000%' }, 
                { value: 'other', label: 'Other'}
            ],
...
}

And my DT init for that column

{ "data": "3", "className": "format_column", "searchable": true }

I'm guessing it might be more related to datatables and not yadcf, seeing the value sent ajax post is just "100" disregarding the "%" thereby also matching 1000% items. I thought 1.10x would auto detect and deal with percent stuff itself. Maybe I'm wrong? I tried adding "type: percent" and "type: number" as part of DT's column init but no difference.

This question has an accepted answers - jump to answer

Answers

  • daniel_rdaniel_r Posts: 460Questions: 4Answers: 67
    Answer ✓

    When you use server side ("serverSide": true), its up to you to do the matching logic, so instead of checking for string "contains" (when "1000" contains "100" ? -> true) you should use "equal" ("1000" equal "100" ? -> false).

  • organizerorganizer Posts: 7Questions: 1Answers: 0

    Thank you for the tip, much appreciated.

This discussion has been closed.