The multiple selection can be achieved through checkboxes, which exist on each row instead of using a click event on a specific row. The selection is enabled by setting selectionMode as multiple on a column level (remember that plain selection provides this on a table level) and the selection property to hold the selected rows as an array of objects.
The component with the checkbox selection feature to select multiple browser records would be written as follows:
<p-dataTable [value]="basicBrowsers" [(selection)]="selectedBrowser">
<p-header> Multiple Selection </p-header>
<p-column [style]="{'width':'38px'}" selectionMode="multiple">
</p-column>
//Content goes here
</p-dataTable>
The following screenshot shows a snapshot result with a checkbox selection as an example:
In this selection, the selected records can be unselected by unselecting checkboxes. The checkbox selection supports the onHeaderCheckboxToggle event while toggling the header checkbox. Refer to the events section for more details.
For example, the value of the browserId property could be chosen for dataKey as follows:
<p-dataTable dataKey="browserId" selection="true">
...
</p-dataTable>