Hello,
1.I want to show detail template in treegrid when a toggle button is clicked.
2.In default detail column need to hide.
3.when button is clicked from a row then only selected row show the detail template rather than all row.
Regards,
Wilma Hill
Hi Farvenn,
I want to
|
App.Component.html
<ejs-treegrid #treegrid [dataSource]='data' height=317 width='auto' childMapping='Children'
(dataBound)='dataBound($event)' (expanded)='expanded($event)'>
<e-columns>
<e-column field = 'Name' headerText='First Name' width='160'></e-column>
<e-column headerText = 'Commands' width=120 [commands]='commands'></e-column>
<e-column headerText = 'Commands' width=120 [commands]='commands1'></e-column>
. . .
</e-columns>
App.component.ts
export class AppComponent{
public data: Object[] = [];
public commands: any;
public commands1: any;
@ViewChild('treegrid')
public treegrid: TreeGridComponent;
ngOnInit() : void {
this.data = textdata;
this.commands = [
{
buttonOption: {
content: 'Expand',
cssClass: 'e-flat',
click: this.onExpand.bind(this) //bind click event for Expand button
}
}
];
this.commands1 = [
{
buttonOption: {
content: 'Collapse',
cssClass: 'e-flat',
click: this.onCollapse.bind(this) //bind click event for Collapse button
}
}
];
}
public onExpand = (args: Event) => {
let DetailRow = < HTMLTableRowElement > (
closest(args.target as Element, '.e-row')
);
DetailRow.nextSibling.style.display = 'table-row'; //display the row on clicking the button
};
public onCollapse = (args: Event) => {
let DetailRow = < HTMLTableRowElement > (
closest(args.target as Element, '.e-row')
);
DetailRow.nextSibling.style.display = 'none'; //Hide the row on clicking the button
};
dataBound(args) {
this.treegrid.grid.detailCollapseAll(); //Collapse detail row on Initial render
}
expanded(args) {
this.treegrid.grid.detailCollapseAll();//Expand detail row on Initial render
}
|