Selecting multiple items
Set the UseMultiCheck parameter to true
When true, a checkbox will be displayed on each row.
UseMultiCheck="true"
The hypergrid supports two different methods of registering a checked item:
- Keep a list of checked items.
- Use a boolean field on the item itself.
Keep a list of checked items
Provide the HyperGrid with a generic List, and the HyperGrid will add selected items, and remove unselected items.
private List<Customer> CheckedItemsList = new List<Customer>();
UseMultiCheck="true" CheckedItems="@CheckedItemsList"
Use a boolean field on the item
This method can be used when you want the checked status to depend on a table field.
You need to provide the HyperGrid with three expressions:
- IsChecked: Return true when the item is to be considered checked. For example "c => c.Company == 1"
- SetChecked: Set the item to checked state. For example "c => c.Company = 1"
- SetUnchecked: Set the item to unchecked state. For example "c => c.Company = 2"
[Parameter]
public Func<ItemType, bool> IsChecked { get; set; }
[Parameter]
public Action<ItemType> SetChecked { get; set; }
[Parameter]
public Action<ItemType> SetUnchecked { get; set; }
UseMultiCheck="true" IsChecked="c => c.IsSelected" SetChecked="c => c.IsSelected = true" SetUnchecked="c => c.IsSelected = false"