Checknode

I have a treeview component, its data is taken from vuex, it seems the checknode doesn't work, I'm doing the category function for my blog, I load the treedata and then I load the post But checknode does not work, please demo me

1 Reply 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team October 20, 2020 12:30 PM UTC

Hi Pham Chi Trung,  
  
Greetings from Syncfusion support. 
 
We have checked your reported problem with TreeView component. You can check the TreeView nodes using any one of the below case. 
 
Case 1: By setting isChecked in datasource. 
 
When isChecked is set to true in dataSource of TreeView component, it automatically checks the corresponding TreeView node. 
 
{ 
        id: 2, 
        pid: 1, 
        name: "Laura Callahan", 
        isChecked: true, 
        eimg: 
        job: "Product Manager", 
        hasChild: true, 
      }, 
 
Case 2:  using checkedNodes API. 
 
You can change the checked nodes of TreeView using checkedNodes property. 
 
Refer to the below code snippet. 
 
methods: { 
    checkNode: function () { 
      var treeViewObj = document.getElementById("treeview").ej2_instances[0]; 
      /*using function for checked nodes*/ 
      treeViewObj.checkedNodes = ["8"]; 
    }, 
  }, 
 
Case 3:  using checkAll method. 
 
You can check the TreeView node by using node id as a argument for checkAll method of TreeView component. 
 
  methods: { 
    checkNode: function () { 
      var treeViewObj = document.getElementById("treeview").ej2_instances[0]; 
      /*using function for checked nodes*/ 
      treeViewObj.checkAll(["9", "8"]); 
    }, 
  }, 
 
Refer to the sample link below. 
 
 
To know more about the TreeView component, refer the below links. 
 
 
 
 
Please let us know, if you need any further assistance. 
 
Regards,  
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon