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

TreeView SelectedValue as a filter for EntityDataSource

6 Answers 103 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Hinek
Top achievements
Rank 1
Hinek asked on 02 Apr 2012, 10:22 AM
I'm trying to use TreeView and GridView with Entity Framework. I have a page with one TreeView, one GridView, each with it's own EntityDataSource. This far it's working.
Now I want to filter the data in the grid, so I configure the Where property of it's datasource to filter where it.CategoryID = @CategoryID. And I bind the parameter @CategoryID to the TreeView.SelectedValue. This doesn't work: All items are shown in the grid regardless which category I select in the tree. :(
If I replace the TreeView with a ComboBox, the filter works ...

6 Answers, 1 is accepted

Sort by
0
Hinek
Top achievements
Rank 1
answered on 04 Apr 2012, 08:22 AM
I just noticed: If I set a default value for the parameter, the GridView is filtered correctly by this value. But it never changes regardless of which node I select in the TreeView.
Do I have to set some property so the selected node's value is used as SelectedValue?
0
Plamen
Telerik team
answered on 05 Apr 2012, 08:13 AM
Hi Hinek,

 
In RadTreeView the SelectedValue property is returning the value of the selected node. You can handle the NodeClick event of RadTreeView and filter the RadGrid according to the clicked node.

Hope this will be helpful.

Kind regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Hinek
Top achievements
Rank 1
answered on 10 Apr 2012, 02:42 PM
So a "selected node" in RadTreeView means a checked node? Isn't this a bit uncommon? In the most controls (including the standard .NET controls) the selected node is the one node that's highlighted. Or am I mistaken?
0
Plamen
Telerik team
answered on 11 Apr 2012, 11:19 AM
Hi Hinek, 

 
It seems that there is some kind of misunderstanding. Please excuse me for that.

Let me clear the behavior of RadTreeView. The selected node is the one that is clicked on or navigated with keyboard to, not the one that is checked. A node is highlighted when the mouse is positioned over it but it is not selected. You can refer to some of our on-line demos where this behavior can be observed.

As for you scenario would you please elaborate at which event are you trying to get the value of the Selected node because it is not very clear what is not working properly. Here is one way to get it on a click of a button:

<telerik:RadButton runat="server" ID="RB" OnClick="RB_Click">
        </telerik:RadButton>
        <telerik:RadTreeView runat="server" ID="RTV">
            <Nodes>
                <telerik:RadTreeNode Text="a" Value="1">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="b" Value="2">
                </telerik:RadTreeNode>
                <telerik:RadTreeNode Text="c" Value="3">
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>
protected void RB_Click(object sender, EventArgs e)
    {
        Response.Write(RTV.SelectedValue);
    }

Here you can the video of my test. 
 
Hope this will be helpful.

Kind regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Hinek
Top achievements
Rank 1
answered on 11 Apr 2012, 02:23 PM
Hi, thanks for the quick reply. I guess we talked past each other. Ok, so when I click a node it is the selected node, that's great, because this is the behaviour I was expecting.
So I guess my problem is the EntityDataSource doesn't notice, that SelectedValue has changed. When I use RadComboBox, the EntityDataSource notices automatically when a new value was chosen (drop-down opened, clicked on a value) and refreshes it's filter. But with the RadTreeView, the EntityDataSource does not react to the change when a node is clicked-->selected.
I'm not sure how EntityDataSource manages stuff like this, it just that it works with the RadComboBox but not with the RadTreeView which is perplexing to me ...
0
Accepted
Plamen
Telerik team
answered on 16 Apr 2012, 01:26 PM
Hello Hinek,

 
RadCombobox and RadTreeView are quire different controls and it is expected that sometimes a scenario that is working properly with one of them by design is not working with the other one. In your case I would recommend you to try to rebind the RadGrid according to the node's value in the onNodeClick server event.

 If this doesn't help please share the code that is working properly with RadCombobox so we can review it and try to provide you with a possible workaround with RadTreeView.

Greetings,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
TreeView
Asked by
Hinek
Top achievements
Rank 1
Answers by
Hinek
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or