bootstrap-table icon indicating copy to clipboard operation
bootstrap-table copied to clipboard

Column filter seperated by space with similar name

Open pietos opened this issue 2 years ago • 7 comments

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.

image

image

Example(s)

No response

Possible Solutions

No response

Additional Context

No response

pietos avatar Sep 25 '23 11:09 pietos

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 image

pietos avatar Sep 25 '23 12:09 pietos

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 image

Extend the escapeID with 1 more line of code: id = String(id).replace(/ /g, "_"); image

As a result it now takes the unique and correct classes image

and the column doesn't break anymore image

pietos avatar Sep 25 '23 12:09 pietos

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 ?

UtechtDustin avatar Oct 01 '23 17:10 UtechtDustin

@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

pietos avatar Oct 02 '23 10:10 pietos

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.

UtechtDustin avatar Oct 02 '23 18:10 UtechtDustin

@wenzhixin any update regarding this issue?

pietos avatar Apr 16 '24 09:04 pietos

There is no update yet.

wenzhixin avatar Apr 17 '24 02:04 wenzhixin