Telerik Forums
UI for ASP.NET MVC Forum
6 answers
534 views

Would someone be able to offer any suggestions on how to display TreeView with certain node paths already expanded based on a "expandFolder" boolean attribute that is returned in the Remote_Data_Binding controller?

I'm using code similar to the below example with an additional "expandFolder" boolean attribute on the database.
https://demos.telerik.com/aspnet-mvc/treeview/remote-data-binding

 

Additionally, when a user clicks a node, the tree needs to fully expand any child nodes whose "expandFolder" is true.

I saw some posts about an "expand: true" setting topic but couldn't figure out how to use that approach with the LoadOnDemand treeview pulling from remote data binding.  I also saw some uses with expandPath.  However, I was hoping there's a way to use the existing node data without having to re-traverse the entire tree since I already set the expandFolder in the Controller?

Thanks in advance for any help,

Gil

 

 

 

Dimitar
Telerik team
 answered on 14 Jun 2019
1 answer
372 views

Hi I am struggling to figure this out...I am trying to pass additional data on the call.  The id that treeview comes up with is always there and correct.  But my roleid is always null.  And the RoleId is valid number.  Running out of places to look so I figured I post...

 

@(Html.Kendo().TreeView()
                                .Name("permissionList")
                                .Checkboxes(true)
                                .DataTextField("name")
                                .DataSource(dataSource => dataSource
                                    .Read(read => read.Action("permissions", "roles", new { RoleId = @Model.RoleId}))
                                )
                    )

 

Controller

        [HttpGet]
        [Route("permissions")]
        [Route("permissions/{id}/{RoleId}")]
        public JsonResult Permissions(int? id, int? RoleId)
        {
            var roleFormMgr = new RoleFormMgr(StateMgmt);
            var roleEntity = roleFormMgr.GetRole(RoleId.GetValueOrDefault());
            var roleFormVM = roleFormMgr.PopulateView(Mapper.Map<RoleForm>(roleEntity));
            var permissions = roleFormVM.RolePermissionList.Where(p => id.HasValue ? p.parentId == id : (id == null && p.parentId == 0)).ToList();
            return Json(permissions, JsonRequestBehavior.AllowGet);
        }

Dimitar
Telerik team
 answered on 29 Apr 2019
3 answers
114 views

I am creating a treeview, loaded from remote hierarchical data, similar to

http://demos.telerik.com/aspnet-mvc/treeview/remote-data-binding

I am trying to understand this line in the controller:

 hasChildren = e.Employees1.Any()

I assume that the employee model has a property where it checks for children.  Where can I actually look at the model?  Can I download all the demos along with the data model?

 

 

Dimitar
Telerik team
 answered on 06 Mar 2019
1 answer
197 views
How can i binding treeview from datatable?? Please help!
Dimitar
Telerik team
 answered on 27 Feb 2019
11 answers
574 views

Hello, I am currently evaluating the Telerik control sets for use in a large project to start soon.  I have a requirement where we will be building a treeview in our ASP.NET MVC controller code using TreeViewItemModel list and passing to the view.  In the view razor code and/or javascript, is there a way to access the TreeViewItemModel as a user is selecting different nodes in the tree?  Specifically, when building the TreeViewItemModel, I populate the .Text and .Id properties and I need to access these values to post back to my controller code to handle the selection changes.  Is this possible? I need to quickly mock something up to demonstrate this.

Controller code to build the treeview contents is here:

public List<TreeViewItemModel> BuildTreeContents()
{
List<TreeViewItemModel> tree = new List<TreeViewItemModel>();
IQueryable<SupplierModel> suppliers = GetSuppliers();
IQueryable<ManagedOrgModel> managedOrgs = null;
IQueryable<ManagedLocationModel> locations = null;
TreeViewItemModel node = null;
List<TreeViewItemModel> orgs = null;
List<TreeViewItemModel> locs = null;
foreach (SupplierModel supplier in suppliers)
{
node = new TreeViewItemModel();
node.Text = supplier.SupplierName;
node.Id = supplier.SupplierID;
managedOrgs = GetManagedOrgs(supplier.ClientID, supplier.SupplierID);
orgs = new List<TreeViewItemModel>();
foreach (ManagedOrgModel managedOrg in managedOrgs)
{
TreeViewItemModel orgNode = new TreeViewItemModel();
orgNode.Text = managedOrg.ManagedOrgName;
orgNode.Id = managedOrg.ManagedOrgID;
locations = GetLocations(managedOrg.ClientID, managedOrg.SupplierID, managedOrg.ManagedOrgID);
locs = new List<TreeViewItemModel>();
foreach (ManagedLocationModel location in locations)
{
TreeViewItemModel locationNode = new TreeViewItemModel();
locationNode.Text = location.ManagedLocationName;
locationNode.Id = location.ManagedLocationID;
locs.Add(locationNode);
}
orgNode.Items = locs;
orgNode.HasChildren = true;
orgs.Add(orgNode);
}
node.Items = orgs;
node.HasChildren = true;
tree.Add(node);
}
return tree;

 

Thanks,

Doug Matulis

Dimitar
Telerik team
 answered on 21 Feb 2019
1 answer
186 views
     Is it possible to have a checkbox treeview within a listbox and have it so that when a parent item is checked, the parent and all of its children can be moved to a selected side of the listbox?
Ivan Danchev
Telerik team
 answered on 06 Feb 2019
1 answer
168 views

So lets say I have a set of entities

          ObjectModel1 - Id, Name, List<ObjectModel2> Children

          ObjectModel2 - Id, Name, Note, DateModified, ModifiedBy

So now my dataset might return

          ObjectModel1 om1a

                    ObjectModel2 om2a

                    ObjectModel2 om2b

          ObjectModel1 om1b
                    ObjectModel2 om2c
                    ObjectModel2 om2d

This would come down as a List<ObjectModel1> object with the ObjectModel1 objects in the list having the ObjectModel2 objects as children.

I would like to display this so that each of the ObjectModel1 objects are displayed as separate trees with all of the data from each ObjectModel2 object being displayed when the ObjectModel1 trees are expanded.

So, first of all, is this possible with the Kendo treeview, and if not, what would we use?  Second, even if it is possible, is there a better UI component to do the above?   

Ivan Danchev
Telerik team
 answered on 25 Jan 2019
7 answers
1.0K+ views

Hello,

Would someone be able to offer the solution on how to get certain node's data which is dynamic loaded (load on demand)?

The case is that in my MVC project the top level node have already be loaded on TreeView . I need load second level to fourth level node based on every level's condition (on one button click). My problem is I cannot get second level's detail data (after the nodes appended to top level ) which third level depend on. When I do the debug the count of second level nodes showed correctly, but not detail data anywhere. Do you have some suggestions? Thanks in advance!

Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
 answered on 18 Jan 2019
3 answers
82 views

Something is not clicking for me on this, and I am not really sure where to start.  I have what amounts to a directory structure I am sending from the server (see json below) and trying to load into the treeview.  However, I am getting an error stating .  Everything I have been able to find on that pretty much says that I need to define the schema.  This is taking too long for me to figure out and any help would be appreciated.

 

01.{
02.  "FolderId": 1,
03.  "Name": "root",
04.  "Description": "root description",
05.  "Note": "root note",
06.  "Parent": null,
07.  "Children": [
08.    {
09.      "$id": "1",
10.      "FolderId": 2,
11.      "Name": "Sub Level 1",
12.      "Description": "Sub Level 1 description",
13.      "Note": "Sub Level 1 note",
14.      "Children": [],
15.      "Documents": [
16.        {
17.          "$id": "2",
18.          "DocumentId": 2,
19.          "Name": "PepsiCo Medical Test Doc with picture.docx",
20.          "Note": "Copied from Document.Version 1.1",
21.          "Description": null,
22.          "DocType": 1,
23.          "Status": 3,
24.          "AllVersions": [],
25.          "DocumentHistories": [],
26.          "ViewingRoles": null,
27.          "CurrentUserId": "00000000-0000-0000-0000-000000000000",
28.          "Versions": [],
29.          "PublishedVersion": null,
30.          "LatestDraftVersion": null,
31.          "LatestVersion": null,
32.          "Disposed": false
33.        }
34.      ],
35.      "Disposed": false
36.    },
37.    {
38.      "$id": "3",
39.      "FolderId": 3,
40.      "Name": "Sub Level 2",
41.      "Description": "Sub Level 2 description",
42.      "Note": "Sub Level 2 note",
43.      "Children": [
44.        {
45.          "$id": "4",
46.          "FolderId": 4,
47.          "Name": "Sub Level 2_1",
48.          "Description": "Sub Level 2_1 description",
49.          "Note": "Sub Level 2_1 note",
50.          "Children": [],
51.          "Documents": [
52.            {
53.              "$id": "5",
54.              "DocumentId": 1,
55.              "Name": "PepsiCo Medical Test Doc with picture.docx",
56.              "Note": null,
57.              "Description": null,
58.              "DocType": 1,
59.              "Status": 2,
60.              "AllVersions": [],
61.              "DocumentHistories": [],
62.              "ViewingRoles": null,
63.              "CurrentUserId": "00000000-0000-0000-0000-000000000000",
64.              "Versions": [],
65.              "PublishedVersion": null,
66.              "LatestDraftVersion": null,
67.              "LatestVersion": null,
68.              "Disposed": false
69.            }
70.          ],
71.          "Disposed": false
72.        }
73.      ],
74.      "Documents": [],
75.      "Disposed": false
76.    }
77.  ],
78.  "Documents": [],
79.  "Disposed": false
80.}
Veselin Tsvetanov
Telerik team
 answered on 18 Jan 2019
1 answer
315 views

Hi

I have issue with Kendo treeview expanding in my MVC project. I try to expand treeview node (which have children nodes) at same time when I select it. The code went through in .js file without error.  but node didn't expand. Could any one tell me what properly be wrong? below are piece of code.  Thanks.

 

        var selectedNode = $("#treeView").data('kendoTreeView').dataItem(e.node); // selectedNode have correct data after this.
        var treeView = $("#treeView").data('kendoTreeView');
        treeView .expand(selectedNode); //Code went through without error

 

 

Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
 answered on 28 Dec 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?