Depending on the use case, you might want to restrict the user to only allow single selection in a datagrid. If you haven't done so, please read the previous section on general selection first.
[(clrDgSelected)]
, add a
[(clrDgSingleSelected)]
two-way binding on the datagrid itself, to have access to the currently selected item. Note that by setting this value
yourself, you can dynamically select an element if you need to.
In the following example, we simply display the name of the selected user, but since we have access to the full objects, we could perform any operation we want on it.
Selected user: No user selected. {{singleSelected.name}}
Selected user: No user selected. {{trackByIndexSingleSelected.name}}
Selected user: No user selected. {{trackByIdSingleSelected.name}}
Selected user: No user selected. {{trackByIdServerSingleSelected.name}}