Column filter seperated by space with similar name
Bootstraptable version(s) affected
1.22.1
Description
I have auto generated columns where the data-field contains a space. When you search on a record it will result in a situation where after the search the focus will be on a different column.
It has something to do with the fact that the name of the column is placed as a css class and it's similar to the neighbour column because of the space in the field-name.
Example(s)
No response
Possible Solutions
No response
Additional Context
No response
I managed to find out that it happens because this function splits everything on a space and then searched for the class that starts with bootstrap-table-filter-control-
bootstrap-table-filter-control.js line 4304
I managed to fix this, can somebody verify for me if this is it okay and commit it ?
bootstrap-table-filter-control.js line 4828 - 4835 you have to wrap the column.field in the escapeID
Extend the escapeID with 1 more line of code:
id = String(id).replace(/ /g, "_");
As a result it now takes the unique and correct classes
and the column doesn't break anymore
The file bootstrap-table-filter-control.js don't have 4000+ lines, it only have 566 lines.
Also i'dont think we support fields with spaces and i also think we should not support it.
It's such a edge case, no body (should) use it.
What do you think @wenzhixin @djhvscf ?
@DustinUtecht @wenzhixin Sure you have a point there, but not escaping those column fields for the css classes is also a bit strange in my opinion. We connect the table to a mongoDB database, and the data keys in there can contain spaces which should not be a problem. If we just escape the values before assigning them as a CSS class the whole problem is solved.
Also regarding the line numbers, you looked in the src folder, the file I mentioned is from the dist folder.
https://github.com/wenzhixin/bootstrap-table/blob/develop/dist/extensions/filter-control/bootstrap-table-filter-control.js
We never check/develop in the dist folder. Please note down the lines in the src code if possible. Let us wait for the opinion of @wenzhixin and @djhvscf.
@wenzhixin any update regarding this issue?
There is no update yet.