contributte / datagrid

:muscle: DataGrid for Nette Framework: filtering, sorting, pagination, tree view, table view, translator, etc
https://contributte.org/packages/contributte/datagrid/
MIT License
290 stars 194 forks source link

Two datagrids (different components) on same page - ItemsDetail bug #805

Open BigOHenry opened 5 years ago

BigOHenry commented 5 years ago

Hello, when i have two different datagrids (different components) on the same page and both has ItemDetail function there is a conflict:

Use case 1: 1) datagrid 1 - click at eye on row with primary key 10 and item detail is shown correctly and click again to close it. 2) datagrid 2 - click at eye on row with primary key 10 (different data but same key) -> on datagrid 1 is shown detail on row with key 10 = Eye buttons from key 10 from both datagrids showing detail from datagrid 1

Use case 2: 1) datagrid 2 - click at eye on row with primary key 10 and item detail is shown correctly and click again to close it. 2) datagrid 1 - click at eye on row with primary key 10 (different data but same key) -> on datagrid 2 is shown detail on row with key 10 = Eye buttons from key 10 from both datagrids showing detail from datagrid 2

If there are no same keys, everything working correctly but when there are same keys in both datagrids, depends which one has been clicked first.

peldax commented 5 years ago

@paveljanda This is a bug in javascript. Results of itemDetail requests are cached (hidden), but the jQuery selector is global and not restricted to current datagrid only - Therefore cached version from first datagrid is found and shown.

BigOHenry commented 5 years ago

Any idea how to fix it?

peldax commented 5 years ago

You need to modify jquery selectors to operate only on current datagrid - currently it searches globally.