vedmack / yadcf

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

Range filters don't work with function properties #627

Open cpdog opened 4 years ago

cpdog commented 4 years ago

See: http://live.datatables.net/ziqipodu/1

Note that the property "doubleAge" is defined as a function. DataTables will execute the function to retrieve the property value. For the "select" filter type, yadcf works properly and filters the data properly. For the range filters however, yadcf doesn't filter at all.

This appears to be because the dot2obj function has the following code

    dot_refs = dot_refs.split(".");
    for (i = 0; i < dot_refs.length; i++) {
        if (tmpObj[dot_refs[i]] !== undefined && tmpObj[dot_refs[i]] !== null) {
            tmpObj = tmpObj[dot_refs[i]];
        } else {
            return '';
        }
    }

This doesn't consider that a property may be a function. Consequently, the filter is comparing against the function definition rather than the result of the function invocation.

cpdog commented 3 years ago

@vedmack let me know if you need any more info about this bug or if I messed up the PR.