Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] searchFieldDrop's index might be null #2140

Open
mpf82 opened this issue Nov 4, 2021 · 1 comment
Open

[BUG] searchFieldDrop's index might be null #2140

mpf82 opened this issue Nov 4, 2021 · 1 comment
Labels
2.0 2.0 branch / release Bug This needs fixing

Comments

@mpf82
Copy link
Collaborator

mpf82 commented Nov 4, 2021

searchFieldDrop's index might be null if searching for a field that is not part of the grid (which in our application is a common usecase, to filter based on database fields that are not displayed in the grid).

In that case, this.getSearch(sd.field, true) returns null and as a result, the HTML of the search action contains searchFieldDrop|null|0|this.

grafik

If you now click on such a search action, the following error will be raised:

w2ui.js:4291 Uncaught TypeError: Cannot read properties of undefined (reading 'type')
    at w2grid.searchFieldDrop (w2ui.js:4291)
    at HTMLSpanElement.<anonymous> (w2ui.js:1943)
    at HTMLSpanElement.dispatch (jquery-3.6.0.js:5430)
    at HTMLSpanElement.elemData.handle (jquery-3.6.0.js:5234)

Using sd_ind (and searchData) in such a case will probably not work, because the search data is unlikely to contain a type property.

Maybe text should be assumed as fallback type in such a case? And searchData[sd_ind].field / searchData[sd_ind].operator could be used as fallback for sf.field / sf.operators.

@mpf82 mpf82 added Bug This needs fixing 2.0 2.0 branch / release labels Nov 4, 2021
@vitmalina
Copy link
Owner

This has been refactored in the past few weeks and I think it is working fine now. However, can you check and close this issue if all good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 2.0 branch / release Bug This needs fixing
Projects
None yet
Development

No branches or pull requests

2 participants