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

Node Security

2 Answers 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 28 Sep 2010, 08:15 PM
I have a scenario I'd like to know if you can help me with...

I want to populate a TreeView using a Linq data source. This is because there is going to be another page that graphically allows admins to add/edit/delete/re-order nodes. When the admins work with this page, they will obviously be able to see all the nodes.

Now on the actual page that the TreeView is going to be available to the general public, I want to be able to programatically limit which nodes are visible to the user based on active directory groups. Is there a way to turn nodes visible/hidden after the dataset has been returned from the Linq query? How would I accomplish this?

Thanks for the assistance!

2 Answers, 1 is accepted

Sort by
0
Accepted
Veronica
Telerik team
answered on 29 Sep 2010, 03:18 PM
Hello Philip Senechal,

You can subscribe to the OnNodeDataBound event and show/hide nodes in the handler.

Please take a look at this help topic.

All the best,
Veronica Milcheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Philip Senechal
Top achievements
Rank 1
answered on 04 Oct 2010, 10:29 PM
Thanks Veronica!

I used that event and some creative code that reads through a List object stored in a session variable containing the current user's Active Directory group membership to turn nodes on and off. Works GREAT!

protected void RadTreeView1_NodeDataBound(object sender, RadTreeNodeEventArgs e)
{
    e.Node.Visible = false;
 
    EISDataContext db = new EISDataContext();
    var query = from navsecurity in db.tLeftNavSecurities
                where navsecurity.NavID == int.Parse(e.Node.Value)
                select navsecurity;
 
    foreach (tLeftNavSecurity navsecurity in query)
    {
        if ((Session["s_myADGroups"] as List<DataAccess.Group>).Find(delegate(DataAccess.Group g) { return g.Name == navsecurity.NavGrp; }) != null)
        {
            tLeftNav nav = db.tLeftNavs.Single(p => p.NavID == int.Parse(e.Node.Value));
 
            if (nav.NavActInd == "Y")
            {
                e.Node.Visible = true;
                e.Node.Expanded = true;
            }
        }
    }
}
Tags
TreeView
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Philip Senechal
Top achievements
Rank 1
Share this question
or