@Input() context: GridContext;
- // Track the context menus so we can manually close them
+ // Track the context menus so we can manually close them
// when another popover is opened.
contextMenus: NgbPopover[];
action.action(this.context.getSelectedRows());
}
- // Apply row selection, track the new menu if needed,
+ // Apply row selection, track the new menu if needed,
// manually close any existing open menus, open selected menu.
onRowContextClick($event, row: any, contextMenu: NgbPopover) {
$event.preventDefault(); // prevent browser context menu
return;
}
- this.handleRowClick($event, row);
+ if (!this.context.rowIsSelected(row)) {
+ // If the focused row is not selected, select it.
+ // Otherwise, avoid modifying the row selection.
+ this.context.selectOneRow(this.context.getRowIndex(row));
+ }
const existing = this.contextMenus.filter(m => m === contextMenu)[0];
if (!existing) {
this.contextMenus.push(contextMenu);
}
- // Force any previously opened menus to close, which does
+ // Force any previously opened menus to close, which does
// not naturally occur via context-click.
this.contextMenus.forEach(m => m.close());
<ng-container *ngIf="action.separator">
<div class="dropdown-divider"></div>
</ng-container>
- <ng-container *ngIf="action.group && !action.isGroup">
- <!-- grouped entries are indented -->
- <span class="ml-4">{{action.label}}</span>
- </ng-container>
<ng-container
*ngIf="!action.group && !action.isGroup && !action.separator">
<span class="ml-2">{{action.label}}</span>
}
performAction(action: GridToolbarAction) {
+ if (action.isGroup || action.separator) {
+ return; // These don't perform actions
+ }
const rows = this.gridContext.getSelectedRows();
action.onClick.emit(rows);
if (action.action) { action.action(rows); }