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 item. The following screenshot shows a snapshot result with single selection as an example:
To notify that single selection has worked or not, we displayed the selected record information in a footer section...