We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to use the CheckItem method in ListView

Hi,

I have the following ListView in my app:

 <EjsListView @ref="ejsListView" DataSource=@_appConfig.ConfigVizObjs.ConfigVizObj ShowCheckBox="true">
     <ListViewEvents Selected="@onListViewSelected" TValue="ConfigVizObj"></ListViewEvents>
     <ListViewFieldSettings Id="Id" Text="Desc" GroupBy="DisplayDesc"></ListViewFieldSettings>
 </EjsListView>


I want to check some items in this ListView based on the Text field after the list has been populated, based on some other events. How do I use the CheckItem method to achieve this? I have tried some options, including e.g.

ejsListView.CheckItem(new { Text = "BankingBookLVL3", Id= "BankingBookLVL3" });

But I cant seem to get it to work. Please give an example?

Regards,

RC

1 Reply

SP Sowmiya Padmanaban Syncfusion Team February 11, 2020 06:21 AM UTC

Hi Ruan,  
 
Greetings from Syncfusion support. 
 
We have checked your reported issue that how to check the item using CheckItem() method.  Refer the below code snippet for check the items in ListView based on fields value. 

  private DataModel[] Data = { 
        new DataModel { Text ="Hennessey Venom", Id = "list-01" }, 
        new DataModel { Text = "Bugatti Chiron", Id = "list-02" }, 
        new DataModel { Text = "Bugatti Veyron Super Sport", Id = "list-03", IsChecked = true }, 
        new DataModel { Text = "SSC Ultimate Aero", Id = "list-04" }, 
        new DataModel { Text = "Koenigsegg CCR", Id = "list-05" }, 
        new DataModel { Text = "McLaren F1", Id = "list-06" }, 
        new DataModel { Text = "Aston Martin One- 77", Id = "list-07" }, 
        new DataModel { Text = "Jaguar XJ220", Id = "list-08" }, 
        new DataModel { Text = "McLaren P1", Id = "list-09" }, 
        new DataModel { Text = "Ferrari LaFerrari", Id = "list-10" } 
    }; 
  public void CheckItem () 
    { 
        list.CheckItem(new DataModel { Id = "list-02" }); 
    } 
 
For your reference, we have prepared a simple sample. In that sample, we have checked the item during button click. Refer the sample link below. 
 
Please let us know, if you need any further assistance on this. 
 
Regards,  
Sowmiya.P 


Loader.
Live Chat Icon For mobile
Up arrow icon