Bind TreeView node data after call to CRUD insert method

I am using TreeView and server-side data.
I am trying to add a new node to the tree, with its data values populated from the server.


Here is my Razor code:

        @Html.EJS().TreeView("mytree").LoadOnDemand(true).NodeTemplate("#treeTemplate").Fields(field =>
            field.Id("ID")
            .ParentID("ParentID")
            .Selected("selected")
            .Expanded("expanded")
            .Text("Name")
            .HasChildren("hasChild")
            .DataSource(ds => { ds.Url(Url.Action("TreeData"))
                .Adaptor("UrlAdaptor")
                .InsertUrl(Url.Action("TreeInsert"))
                .UpdateUrl(Url.Action("TreeUpdate"))
                .RemoveUrl(Url.Action("TreeRemove"))
                .Offline(false)
                .CrossDomain(true); })
            ).Render()

Javscript being called when Adding a new node to nodeid # 99  (using Context Menu handler)
       item = { ID:0, parentId = 99, Name = "test" };
      treeObj.addNodes([item], parentId, false);


partial C# code:

        public ActionResult TreeData(int id, DataManagerRequest dm) {
           return Json(treedata);
       }

        public ActionResult TreeInsert(CRUDModel crud) {
               var newNode = new Node();
               newNode.ParentID = crud.Value.ParentID;
               // set some values here, like parentId, Name, etc.

               dataContext.Nodes.Add(newNode);
               dataContext.SaveChanges;

              // After SaveChanges,  newNode will have its ID property set to SQL Identity value (auto-incremented)
           return Json(newNode);
        }




The automatic CRUD insert call is successful.

TreeView addNodes() -> /TreeInsert payload:
{"value":{"ID":0,"Type":2,"ParentID":99,"Name":"test","Icon":"icon-chat"},"action":"insert"}

The server responds with the full node data needed to set the values in the node, including the new node ID index value.
Response:
{"ID":1005,"ParentID":99,"Name":"New Text","Type":2,"Icon":"icon-chat"}

However the Tree does NOT refresh the node values to set the custom data properties.
The new node is added to the Tree, but still displays "test" as its name, and the ID is still zero.  (not the values returned from the Insert call)











1 Reply 1 reply marked as answer

SP Sowmiya Padmanaban Syncfusion Team March 24, 2021 11:46 AM UTC

Hi Robert Gulledge,  
 
Greetings from Syncfusion support. 
 
We have checked your reported problem with TreeView component. Currently, we don’t have support to refresh the updated data returned from server while using CRUD operation in TreeView. We will consider this as feature request from our end. Support for this feature will be included in any one of our upcoming releases. Generally, we will plan any feature implementation based on customer request count, feature rank and wishlist plan for some feature.   
   
Please, track the following feedback link to know the status of this feature implementation.  
  
 
We appreciate your patience. 
 
Regards,  
Sowmiya.P 


Marked as answer
Loader.
Up arrow icon