Search Builder orthogonal not work?
Search Builder orthogonal not work?
Link to test case: https://live.datatables.net/nefehaxu/7/edit?html,js,output
Description of problem:
In the column Office, it is rendered as html flag, and I want to filter this column in Search Builder with the country name.
(This is different than the one from this example, where I don't have country name next to the flag), and I use the option columns.searchBuilder.orthogonal
, setting both search
and display
keys' value to 'filter'
.
In the test case, however, the Office column in the Search Builder is blank because the Search Builder does not take the orthogonal settings into account. I checked the source code, the orthogonal configuration was indeed passed to the SearchBuilder, Criteria and Group at the very beginning. But somehow it uses the default configurations defined before generating Value select dom.
Related lines in the source code I guess are: https://github.com/DataTables/SearchBuilder/blob/d3ec11bd3823b28529547ba4c7f91d12db80cfb0/src/criteria.ts#L2173
https://github.com/DataTables/SearchBuilder/blob/d3ec11bd3823b28529547ba4c7f91d12db80cfb0/src/criteria.ts#L2241
https://github.com/DataTables/SearchBuilder/blob/d3ec11bd3823b28529547ba4c7f91d12db80cfb0/src/criteria.ts#L2438
I was able to fix this issue by changing this line:
https://github.com/DataTables/SearchBuilder/blob/d3ec11bd3823b28529547ba4c7f91d12db80cfb0/src/criteria.ts#L2441-L2446
private _getOptions(): {[keys: string]: any} {
let table = this.s.dt;
return $.extend(
true,
{},
Criteria.defaults,
table.settings()[0].aoColumns[this.s.dataIdx].searchBuilder
);
}
into
private _getOptions(): {[keys: string]: any} {
let table = this.s.dt;
return this.c;
}
It seems that there is no searchBuilder
inside aoColumns[this.s.dataIdx]
before calling the function _getOptions()
, which returns undefined
, but I've made too many changes to the source code (to be able to use React) so I'm not quite sure.
Answers
Ah! I found a post two years ago and it turns out that I put it in the wrong place!
https://datatables.net/forums/discussion/comment/209587/#Comment_209587
After modifying to this: https://live.datatables.net/nefehaxu/8/
It works fine.
I think maybe there could be a global configuration for all columns like I did for the fix above.
That's a good idea - I'll keep it in mind for when I rewrite SearchPanes. It needs an overhaul... Good to hear you've got it working as you need.
Allan