-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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
[Feature Request] Add option to only select one row at a time in data tables #2960
Comments
Yep, would like this as well. Was fixing to start writing some code, to attempt, to do something similar. |
As a workaround, you can just use
Note: Don't specify |
Yes! This feature would be great. @benjaminpwarren Could you please make a quick example on Codepen or Fiddle about how it works? Cheers |
(Note that in my snippet in my previous post, I used Edit: I've just noticed that the selected radio doesn't 'move' when the table is sorted. There's probably a quick fix and I'll look into when I get a chance. |
Thanks, @benjaminpwarren! I'll have a look!! |
Thanks for publishing the example for selecting a row with a radio button. Have you discovered how to fix the fixed selected radio button? When I select a row and skip to the next page, the radio button keeps selected in the new page. Best regards |
In case someone comes across this and needs a fix still for the workaround @benjaminpwarren posted, you can just add a unique :key="" to the v-radio. In the codepen example it'd be :key="props.item.name" The problem is when you page the data table it attempts to reuse the v-radio components. In Vuetify's checkbox version this doesn't matter since the checkbox values are forced to update to match their corresponding rows' props, whereas in the radio group case the value of the radio is unchanging. |
As I didn't want my table to be covered in auxiliary radio buttons, my work-around solution to this was to set a data object equal to the item of the clicked row and then check against it during the calculation of the |
Hey guys, wouldn't it be better if we use this way? <tr @click="selected = (selected===props.index?null:props.index)">
<td>
<v-checkbox :input-value="selected === props.index" primary hide-details></v-checkbox>
</td>
</tr> I found it works well. |
The best solution for me was to just recode the method <tr :active="props.selected" @click="select(props.item)"> select(selectedItem) {
this.selected = [];
this.items.forEach(item => {
if (item.id == selectedItem.id) {
this.selected.push(item);
}
}) All remaining code is the same. Complete solution here. |
Yes! This feature would be great. Me too! |
Yep, I also need this feature. |
New Functionality
Option to select one row at a time in a data table, radio-button style. Selecting a new row will clear the previous selection.
Improvements
No existing workaround
Bugs or Edge Cases it Helps Avoid
Allows the user to provide extra functionality in custom components based on a guaranteed single-row selection in the data table; a preview pane, for example.
The text was updated successfully, but these errors were encountered: