This is a migrated thread and some comments may be shown as answers.

Load Hierarchy for specified ParentId

4 Answers 17 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
Joel asked on 20 Dec 2018, 11:19 PM

All of your examples don't show me how to load the TreeList with data from a specified ParentId.  Correct me if I'm wrong, but I believe this is the load order (MVC):

  1. Call the Controller Index method to load the View.
  2. View is loaded then the TreeList is initialized which begins the Binding.
  3. Binding calls the TreeList.Read() method to get the hierarchy data (From the GroupsController, AllJson method in my case)

My read definition looks like this:  

.Read(read => read.Action("AllJson", "Groups"))

My problem is I don't see where it lets me specify which root node I want it to initialize the Read from. If I have 200 Hierarchies and I want #134 loaded into the TreeList how do I specify that?

Also, I must load a Hierarchy based on a person's authorization.  That may mean that they are only able to see a branch from a Hierarchy.  How do I accomplish this?

It would make sense to pass the index of a parent node something like this (not real): 

Read(read => read.Action("AllJson", "Groups", ViewBag.ParentId))

Thanks in advance for your help,

Joel

4 Answers, 1 is accepted

Sort by
0
Accepted
Preslav
Telerik team
answered on 25 Dec 2018, 11:32 AM
Hello Joel,

If I understand correctly, your project requires displaying only part of the tree in the view? Please correct me if I am wrong. If this is the case, this is not doable out-of-the-box. The only thing that I could suggest, to achieve a behavior similar to the desired one, is applying a default filter to the dataSource.
Further, about sending additional data to the server, this is doable via the Data method:
To do that, provide a name of a JavaScript function which will return a JavaScript object with the additional data.

Please, check the above resources, and let me know if I can assist you any further or if I missed something.
 

Regards,
Preslav
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
answered on 02 Jan 2019, 04:07 PM

You are correct.  Each tree node represents a group.  When a user is authorized for a group they are able to its children but not its parents.  According to the TreeList, it just displays back the hierarchy it gets... but, the Controller needs to receive the Id of the node that the user is authorized for in order to only get back the appropriate data.

I will attempt to follow the Data method.  This shows promise.

0
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
answered on 02 Jan 2019, 06:26 PM

Your Data method got me there.  Thank you.

However, your documentation needs to be improved.  Telerik causes itself a lot of unneeded activity by providing examples that mean nothing.  This just prompts follow-on questions.  Don't just show what works... show what your developer/users would likely be attempting to accomplish.

For example, the Razor documentation shows the following script is needed that would never be used:

<script>
    function productsReadData() {
        return {
            firstName: "John",
            lastName: "Doe"
        };
    }
</script>

 

Instead, show me how I would get a real value from the Controller that has moved me to this View.  In my case, I use the ViewBag so my script looks like this:

<script>
    var groupId = Number(@(ViewBag.GroupId));
 
    function groupsRead() {
        alert(groupId);
 
        return { id: groupId };
    }
 
</script>

 

In my case, I went on a search on how to do this but having real examples in your documentation would support your customers better and reduce the number of follow-on questions you must answer.

0
Preslav
Telerik team
answered on 07 Jan 2019, 12:58 PM
Hello Joel,

Thank you for sharing your feedback about the docs. Based on it, I logged an issue in our internal system.


Regards,
Preslav
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeList
Asked by
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
Answers by
Preslav
Telerik team
Joel
Top achievements
Rank 1
Veteran
Iron
Iron
Share this question
or