简体   繁体   中英

Angular 4 Kendo grid expand detail template by clicking on the row instead of the arrow

I found this link but it has been a while so I wanted to see if this has been implemented. I had a hard time finding a solution to what I am trying to accomplish.

Opening the kendoDetailTemplate programmatically

You can utilize the cellClick event, and the expandRow function to open the detail-row, when the user clicks a cell.

Detailed information on those options (and more) can be found on their API Reference .

*.html

<kendo-grid
    (cellClick)="onCellClick($event)"
>
    ...
</kendo-grid>

*.ts

onCellClick(event: CellClickEvent) {
    event.sender.expandRow(event.rowIndex);
}

I've also prepared a Plunker to show the code above in action.

declare you viewChild

 @ViewChild('grid') private grid;

then call the below method from onclick. Pass row index as param.

 expandRow(i: number) {
  this.isRowExpanded = !this.isRowExpanded;
  this.isRowExpanded ? this.grid.collapseRow(i) : this.grid.expandRow(i);
}

You can get the row index by

ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM