-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat: conditional selectability of grid items #7974
Conversation
const isSelectable = this._grid.__isItemSelectable(item); | ||
checkbox.readonly = !isSelectable; | ||
checkbox.hidden = !isSelectable && !selected; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rolf specifically suggested to use this behavior.
* | ||
* @type {(item: !GridItem) => boolean} | ||
*/ | ||
isItemSelectable: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other similar APIs, such as part name generator or isCellEditable
, use a row model instance (see __getRowModel
). However that only works if you have a row instance available, whereas this can also be called for items that don't have a rendered row. Not sure if we need to align this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed this and decided to only pass the item. Technically we could construct a row model object from the item itself before passing it to the function, but that would potentially require iterating over all grid caches to figure out the flat row index, or whether an item is a nested one. If we later on want to add support for select all, we'll have to run this function in some way or another over all grid items, at which point this could become a performance issue.
# Conflicts: # packages/grid/src/vaadin-grid-selection-column-mixin.js
Quality Gate passedIssues Measures |
This ticket/PR has been released with Vaadin 24.6.0.beta1 and is also targeting the upcoming stable 24.6.0 version. |
Adds a
isItemSelectable
property that can be configured with a function to conditionally allow or disallow changing the selection state, so both selecting and deselecting, of individual items by the user. Programmatic selection is not affected.Checkboxes for non-selectable items are either hidden, if they are unselected, or readonly if they are selected. The select all checkbox is hidden as well when conditional selection is used.
Part of #1947