selectItem not working

Hello,

I've got a list of accounts in an Angular ListView. I'm trying to select the first one when the page loads. My method is linked to the actionComplete event. Here's the method:



  selectFirstItem(args?:any){

      this.listObj?.selectItem(args.data[0]);

  }


Yet the code doesn't select the first item. Please advise.


1 Reply

LD LeoLavanya Dhanaraj Syncfusion Team August 12, 2024 06:03 PM UTC

Hi Cory,


Greetings from Syncfusion support.


Based on the information you provided, we understand that you want to select the first list item inside the ListView's actionComplete event. In response to your requirements, we have prepared an Angular ListView sample using the latest version. Here, we have passed the first list item field object to the selectItem method inside the actionComplete event.


Check out the sample and code snippets below for your reference.


Sample : https://stackblitz.com/edit/angular-fsuzwr-vix6uu?file=src%2Fapp.component.html,src%2Fapp.component.ts


[app.component.html]

<ejs-listview

    #list

    id="sample-list-flat"

    [dataSource]="data"

    (actionComplete)="onActionComplete($event)"

></ejs-listview>

 

[app.component.ts]

@ViewChild('list')

public listObj: ListViewComponent;

 

onActionComplete() {

    console.log('Action complete event is triggered');

    this.listObj.selectItem({ text: 'Hennessey Venom', id: 'list-01' });

}


Output screenshot:



Please get back to us if you need any further assistance.


Regards,

Leo Lavanya Dhanaraj


Loader.
Up arrow icon