Closed permafrost06 closed 1 year ago
Alternatively, we could expose a prop index-col
. We could use this column for both the internal v-for
key
and for the checkbox index
This linked pr is not complete yet.
This linked pr is not complete yet.
That is fine. You can convert it to a draft pr if you want.
Add checkboxes to each row. Show the checkboxes when prop
checkbox
is true. Internally, an identifier of the selected rows will be stored in an array. expose this array to parent withv-model:checked
.The value of prop
checkbox-index
* will be thename
of a column and the value of this column in the row will be added to the array when the row is selected.
Normally the v-model
prop refers to the value of a certain component. In this case the value is the :data
prop. This can be converted into v-model
if you'd like to.
Since being checked or not checked is for every row, how about we add an extra column named checked
in these data? (This how it's done now).
As v-model
is two-way data binding, changes will be reflected both from parent and child. And the plus point is that we won't have to track checked and non-checked rows separately.
Another advantage of this design is we don't need to add checkbox-index
as the whole row can be easily identified.
v-model:checked
will be an array with the values of a column of the selected rows. The default value of checkbox-index
will be the first column.
If the v-modeled array is changed on parent, the table's checkboxes may be updated to reflect the change. If this functionality becomes too complex, we may not support this particular feature.
Can we rename checkbox-index
to index
? What do you think @protibimbok ?
Can we rename
checkbox-index
toindex
? What do you think @protibimbok ?
Only index
might be a bit confusing as it is used in other cases. We should use something more declarative.
How about check-by
?
I'm not feeling check-by
. Let me know if you have any other suggestions. @protibimbok
closed with #26
Add checkboxes to each row. Show the checkboxes when prop
checkbox
is true. Internally, an identifier of the selected rows will be stored in an array. expose this array to parent withv-model:checked
.The value of prop
checkbox-index
* will be thename
of a column and the value of this column in the row will be added to the array when the row is selected. For example: When a table has columnscheckbox-index
can have valuecheckbox-index="name"
. Then, let's say a row gets selected with the below valueThen, the value of name column of the row ("Some user") will be added to the array.
We have to discuss how we are going to handle the edge cases:
checkbox-index
column. This may prevent the checkboxes from working correctly.*I don't think this is the best name. Let me know if you have any suggestions.