0

I'm using the contextmenu with turbotable of primeng (version 6.1.0).

Based on the demo on the website, when you right click on a row, the context menu appears and the row is selected but when you click outside of the context menu, the menu disappears but the row is still selected. What I want is that the row is deselected when the context menu is hidden.

See https://www.primefaces.org/primeng/#/table/contextmenu

Any ideas how to achieve that?

Dale K
  • 25,246
  • 15
  • 42
  • 71

1 Answers1

6

Add contextMenuSelectionMode="joint" to your p-table object.

Like so:

<p-table [columns]="cols" [value]="cars" selectionMode="single" [(selection)]="selectedCar" [contextMenu]="cm" contextMenuSelectionMode="joint">
    <ng-template pTemplate="header" let-columns>
        <tr>
            <th *ngFor="let col of columns">
                {{col.header}}
            </th>
        </tr>
    </ng-template>
    <ng-template pTemplate="body" let-rowData let-columns="columns">
        <tr [pSelectableRow]="rowData" [pContextMenuRow]="rowData">
            <td *ngFor="let col of columns">
                {{rowData[col.field]}}
            </td>
        </tr>
    </ng-template>
</p-table>

Per https://github.com/primefaces/primeng/issues/5558#issuecomment-404088622

rjpr
  • 61
  • 1
  • 3