0

I have a EJ2 grid that has a dynamic data source and is populating the EJ2 Grid as follows, the issue I am having is that I can't get any feedback on clicking on the cells specifically.

I have tried various approaches from cellClick, actionBegin, cellSelected, cellClick, rowDataBound, queryCellInfo and more.

It is becoming difficult to find what I am after in the syncfusion documentation.

The ej2 grid works and has full CRUD functionality at the moment, just no breakpoints or console.log are being met on the component regardless of which approach I take.

Any advise?

<ejs-grid #grid [dataSource]='dmtable' 
 [toolbar]="toolbarItems"
 [editSettings]="editSettings" 
 [selectionSettings]='selectionOptions'
 height='410px' 
 (toolbarClick)="toolbarClickHandler($event)"
 (cellSelected)="onCellSelected($event)">
  <ng-template #eGridColumns>
    <e-columns>
      <e-column *ngFor="let column of getColumnNames(dmtable)" [field]="column" [headerText]="column"></e-column>
    </e-columns>
  </ng-template>
</ejs-grid>
ngOnInit(){
this.selectionOptions = { type: 'Single', mode: 'Cell' };
}

onCellSelected(args: CellSelectEventArgs) {
  if (args.cellIndexes && args.cellIndexes.length > 0) {
    const firstSelectedCell = args.cellIndexes[0];
    const rowIndex = firstSelectedCell.rowIndex;
    const columnIndex = firstSelectedCell.cellIndexes[0];
    const rowData = this.grid.getCurrentViewRecords()[rowIndex];
    const column = this.grid.columns[columnIndex] as Column;
    const columnName = column.field;
    const cellValue = rowData[columnName];
    console.log('Selected cell value:', cellValue);
  }
}
mcr.netcore
  • 55
  • 1
  • 7

1 Answers1

0

Issue lied with the ngOnInit and not reaching the selectionsOptions due to other calls being made.

mcr.netcore
  • 55
  • 1
  • 7
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 26 '23 at 06:19