Selecting rows in DataTable
In order to perform CRUD operations on the component, there is a need for table row selection. PrimeNG supports various kinds of selections such as single, multiple, radio, and checkbox with different event callbacks.
Single selection
In single selection, the row is selected by a click event on a specific row. This selection is enabled by setting selectionMode
as the single
and selection
property to hold the selected row. By default, the row is unselected with the help of the Meta key (Ctrl key for Windows or Command key for macOS). The row can be unselected without pressing the Meta key just by disabling the metaKeySelection
property.
The component with a single selection feature to select a specific browser record would be written as follows:
<p-dataTable [value]="basicBrowsers" selectionMode="single" [(selection)]="selectedBrowser"> // Content goes here </p-dataTable>
The component class has to define the selectedBrower
object to store the selected...