How to implement Context Menu in Angular Datatable

How to implement Context Menu in Angular Datatable

asheikhasheikh Posts: 6Questions: 3Answers: 0

I have been following https://l-lin.github.io/angular-datatables/#/basic/angular-way documentation to implement datatable in my angular 9. I was successful in implementing datatable but now I need to to use context menu along with it but the documentation doesn't provide anything about context-menu.

Following is the way I am using datatable and I am not able to find any help about how I can use context menu with it.

HTML

<table datatable [dtOptions]="dtOptions" class="table">
</table>

Typescript

import { Component, OnInit, Input, OnChanges } from '@angular/core';

@Component({
  selector: 'app-generic-grid',
  templateUrl: './generic-grid.component.html',
  styleUrls: ['./generic-grid.component.scss']
})
export class GenericGridComponent implements OnInit {

dtOptions: any = {};

data: any = [{
    case_id: 12,
    ai_workflow_primary_sub_type: 'Individual',
    ai_workflow_primary_sub_name: 'Mathew'
  }, {
    case_id: 13,
    ai_workflow_primary_sub_type: 'Organization',
    ai_workflow_primary_sub_name: 'Lemony'
  }, {
    case_id: 14,
    ai_workflow_primary_sub_type: 'Individual',
    ai_workflow_primary_sub_name: 'Lewis'
  }, {
    case_id: 15,
    ai_workflow_primary_sub_type: 'Individual',
    ai_workflow_primary_sub_name: 'John'
  }];

  cols: any = [{
    title: 'Case Id',
    data: 'case_id'
  }, {
    title: 'Primary Subject Type',
    data: 'ai_workflow_primary_sub_type'
  }, {
    title: 'Primary Subject Name',
    data: 'ai_workflow_primary_sub_name'
  }];

  constructor() { }

  ngOnInit(): void {
    this.setDtOptions();
  }

  setDtOptions() {
    this.dtOptions = {
      paging: false,
      info: false,
      responsive: true,
      data: this.data,
      columns: this.cols,
    };
  }
}

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    What do you mean by "context menu" in relation to DataTables? What functionality would you expect it to provide?

  • asheikhasheikh Posts: 6Questions: 3Answers: 0

    By contextmenu I meant Right click menu on rows of datatable. By right clicking on a row a menu of options open where we can perform any actions.

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922

    This example shows how to create table events.

    Kevin

This discussion has been closed.