question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Datatable: Sorters/Filters indexed by Column#field

See original GitHub issue

Describe the defect As of today, sorters and filters are contained in a map indexed by clientId. Using LazyDataModel#load method, actives sorters/filters are transformed into a map where field is the key. At least two reasons for that:

  • UIColumn#columnKey useless at this point
  • Easy for the users to retrieve a specific sorter/filter from this map

If you take that sample #6421 in lazy mode, this will cause a problem since several columns are configured on the same field, basically you’ll end up with less sorters/filters than expected.

1st Solution An easy & quick solution would be to only filter active elements of that map, but key remain UIColumn#columnKey and you lose retrieving sorter/filter by field name. At this point, instead of using maps, lists could be passed as parameters to LazyDataModel#load method

2nd Solution Datatable no longer “authorized” having several columns with same field. Let’s take a more concrete example #5162, the user wants to display three columns “year”. It shows one significant enhancement to do, having a new filter constraint: range. But since it doesn’t exist, he created two additionnal columns from/to, and to identify them with UIColumn#field

As a reminder, UIColumn#field is only relevant when sorting or/and filtering is enabled. Having field as key would ease the impl of methods such as DataTable"updateSortByWithUserSortBy. It would also prevent bug when multiviewstate is enabled, and JSF tree is no longer the same when user comes back on that page (clientId will most likely change, and restoring table state would probably restore a wrong state for a column)

Let me know what you think 😉

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
Rapstercommented, Nov 26, 2020

Does this sample actually work? I’m pretty sure it won’t in lazy mode

0reactions
tandraschkocommented, Dec 15, 2020

You’re only postponing the issue doing so, table component could change position in the JSF tree

Sure but thats another topic. Then we would need on each MultiViewStateAware-component a attr called “mvsKey” instead of the clientId.

It’s not an easy problem to solve as long as columnKey is based on a “volatile” value

users can simple set id=“brand” e.g., its the same as you would index by #field but more flexible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Column name instead of index for sorting/filtering. - DataTables
Suppose we sort by first column, so datatables passes (0, asc) to server, where we need to translate zero to real column name....
Read more >
Sort/filter a datatable by a column which is not included in the ...
Everything works fine except when I want to sort/filter by columns, the total column remains untouched.
Read more >
Sorting and Filtering Data - ADO.NET | Microsoft Learn
The DataView provides several ways of sorting and filtering data in a DataTable: You can use the Sort property to specify single or...
Read more >
DataTable Interactivity - Dash Plotly
Sorting by column ( sort_action='native' ) · Filtering by column ( filter_action='native' ) · Editing the cells ( editable=True ) · Deleting rows...
Read more >
DT: An R interface to the DataTables library - GitHub Pages
DataTables does not provide column filters by default. There is only a global filter (the search box on the top-right). We added a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found