How to use checkItem in listview to programmatically check specific ids on init ?

Im a little confused to what exactly shall I pass as item. Can you give me an example of checkItem()?

3 Replies

SP Sowmiya Padmanaban Syncfusion Team April 21, 2020 07:16 AM UTC

Hi Konnos,  
 
Greetings from Syncfusion support. 
 
We have looked into your requirement about using CheckItem method of ListView to check specific items while initializing the ListView component. When you set the isChecked property as true for particular list item, then those list items will be rendered as checked items on initial rendering of ListView. 
 
Refer the below code snippet and screenshot. 
 
export let checkboxdata: any = [ 
    { "text": "Hennessey Venom", "id": "list-01", "isChecked":true }, 
    { "text": "Bugatti Chiron", "id": "list-02" }, 
    { "text": "Bugatti Veyron Super Sport", "id": "list-03" }, 
]; 
 
 
We would like to let you know that, ListView component would not render completely when ngOnInit method is triggered. So, we will not get the ListView reference in that event and by the time we should not call the checkItems() method of ListView. 
 
In ListView component, we have provided a ActionComplete event. It triggers after the ListView component is fully rendered. 
 
You can achieve your requirement of selecting the items in the ActionComplete event using checkItem method. Please refer the sample code snippets given below: 
 
  actionComplete() { 
      for(var i=0;i<this.checkItem.length;i++){ 
          this.listview.checkItem(this.checkItem[i]); 
      } 
    } 
 
 
Or else we have selectMultipleItems() method, using this method you can check the multiple items in ListView component. For your reference, we have prepared a sample for checking the ListView items. 
 
Refer the sample link below. 
 
To know more about the ListView component. Refer the below links. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 



KK Konnos Kall April 28, 2020 11:39 AM UTC

Thanks a lot :)


SP Sowmiya Padmanaban Syncfusion Team April 29, 2020 03:38 AM UTC

Hi Konnos, 
  
Most welcome. We are happy to hear that your problem has been resolved from our provided solution. Please contact us, if you need any help from us. We will happy to assist you. 
  
Regards,  
Sowmiya.P 


Loader.
Up arrow icon