Closed dvoituron closed 2 weeks ago
✅ All tests passed successfully
Details on your Workflow / Core Tests page.
Love this!
Would probably be good to store the selected state of rows centrally, for example in the InternalGridContext
And also to have Selected
`SelectedChanged` on the DataGridRow so that an initial state can be set programmatically
Finally!! Looking great! Always been using some ugly workarounds to get similar behavior. Could you maybe add the option for an checkbox in the header? Like maybe a parameter SelectMode
with SelectMode.Single
and SelectMode.Multiple
, where the latter adds the header checkbox? And won't this column allow for a bindable "SelectedItems" HashSet in the DataGrid?
Would probably be good to store the selected state of rows centrally, for example in the
InternalGridContext
And also to haveSelected``SelectedChanged
on the DataGridRow so that an initial state can be set programmatically
Columns and attributes already updated
As far as storing the selected state is concerned, this could be an additional feature, but it would probably cause a lot of problems. For example, when using the virtualization function, I'm not sure that all "previous" items are stored in this internal memory. I will check.
Finally!! Looking great! Always been using some ugly workarounds to get similar behavior. Could you maybe add the option for an checkbox in the header? Like maybe a parameter
SelectMode
withSelectMode.Single
andSelectMode.Multiple
, where the latter adds the header checkbox? And won't this column allow for a bindable "SelectedItems" HashSet in the DataGrid?
On the same remark, adding a checkbox in the header seems like a good thing if we have all the data in memory. But we could add this option and an EventCallback to allow the developer to select all the elements.
About Single/Multiple, yes that will be done :-)
@vnbaaij @hksalessio I renamed to these attributes: Property
and OnSelect
.
And I added a bindable SelectAll
property which display a [x] in the column header. So the dev can intercept the SelectAllChanged
(or :after
event) to update his model.
Example
SelectAllChanged="@(all => people.ToList().ForEach(p => p.Selected = (all == true)))"
Nice work @dvoituron thank u for creating this feature. I just have one suggestion when you select one row or more the select all checkbox should change like a (minus) inside the select all checkbox and when you select all it should change to select all. for more explanation I will show it with 2 image.
when you select 1 row or more :
when you select all rows :
Nice work @dvoituron thank u for creating this feature. I just have one suggestion when you select one row or more the select all checkbox should change like a (minus) inside the select all checkbox and when you select all it should change to select all. for more explanation I will show it with 2 image.
That's not the case in Windows Explorer, for example
so we could not have it even with CSS ?
and one more suggestion is very important please if you haven't done it already! when the user click the row I mean anywhere on the it should select not only click on exactly the checkbox.
and one more suggestion is very important please if you haven't done it already! when the user click the row I mean anywhere on the it should select not only click on exactly the checkbo
Already done and included in the GIF above :-)
Updated with
SelectedItems
Gets or sets the list of selected items (in addition with Property
and OnSelect
).
I will write a documentation to explain different uses.SelectMode
selection mode (Single or Multiple).IconIndeterminate
Icon to be rendered when some but not all rows are selected.GIFs in summary are also updated.
I finished the development and updated the description (top of this PR). I still need to add the unit tests to finalize the PR.
Will this feature be released any time soon?
added to milestone v4.7.2
[DataGrid] Multiselect feature, adding a
SelectColumn
There are two ways of managing this
SelectColumn
.Items
and letting the grid manage the selected rows entirely, viaSelectedItems
. property.Or by manually managing the way selected lines are saved, via
Property
,OnSelect
andSelectAll
. This requires more configuration but is probably more interesting when usingVirtualize
or when directly managing a customIsSelected
property.Property
: Function to be executed to display the checked/unchecked icon, depending of you data model.OnSelect
: Action to be executed when the row is selected or unselected.SelectAll
: Value indicating whether the [All] checkbox is selected.These example are using a class containing:
Example
Unit Tests