Hi,
I am trying to highlight/select the row (in grid or treeGrid) without triggering rowSelected.
I tried calling this method, but it triggers rowSelected:
https://ej2.syncfusion.com/angular/documentation/api/grid/selection/#selectrow
Any idea?
Thanks for coming back to me. This is not something I'm looking for.
What you execute .selectRow or selectRows programmatically two things happen:
- row changes colors (appears highlighted)
- rowSelected is triggered
I would like to select a row programmatically without triggering rowSelected.
<div class="control-section">
<ejs-grid [dataSource]='data' (rowSelected)="rowSelected($event)" height='350'>
<e-columns>
. . .
</e-columns>
</ejs-grid>
</div> |
export class AppComponent {
public data: Object[] = [];
ngOnInit(): void {
this.data = orderDetails;
}
rowSelected (args) {
console.log(args.isInteracted);
}
} |
Hi,
Thanks, but in this way we are not blocking rowSelected execution, we are just working around checking if event is triggered programmatically or via user interaction.
I have two places in the solution where I have to select a row programmatically.
In one case, I have to trigger rowSelected, in other case I do not want to do it.
Thanks.
Please consider adding 'emitEvent' boolean option to selectRow.
Please have a look how it behaves in other opinionated frameworks, ie reactive forms:
https://angular.io/api/forms/FormControl#setValue
Kind regards,
Micha
[app.component.ts]
rowSelected(args) {
console.log('Select');
}
onClick(e) {
(this.grid.rowSelected as any).isStopped = true; // Prevented the rowSelected trigger
this.grid.selectRow(0);
setTimeout(
function() {
(this.rowSelected as any).isStopped = false;
}.bind(this.grid),
100
);
} |
Thanks.
Unfortunately provided solution is not a best practice.
Please have a look how similar things are handled in other frameworks. Ie reactive forms:
https://angular.io/api/forms/FormControl#setvalue
So basically:
.selectRow would take an extra argument (triggerRowSelected) stating to trigger or not rowSelected