I have a simple TreeView
<telerik:RadTreeView ID="radTreeViewIndex" runat="server">
</telerik:RadTreeView>
That I am databinding on the page load.
My query returns heirarchical records such as the following
SPOP TheKey SYear Norder
Null A Adult 4000
Null P Pediatric 3000
A A2022 2022 2500
A A2021 2021 2500
A A2020 2020 2500
P P2022 2022 2000
P P2021 2021 2000
P P2020 2020 2000
On the page load, I call the Oracle query, get back a cursor and construct the treeview by binding a data table to it
DataTable dt1 =
new DataTable();
da1.Fill(dt1);
RadTreeView radTreeViewIndex = (RadTreeView)FindControl("radTreeViewIndex");
radTreeViewIndex.NodeDataBound += new RadTreeViewEventHandler(radTVI_click);
radTreeViewIndex.DataFieldParentID = "SPOP";
radTreeViewIndex.DataFieldID = "theKey";
radTreeViewIndex.DataTextField = "sYear";
radTreeViewIndex.DataValueField = "sYear";
radTreeViewIndex.DataSource = dt1;
radTreeViewIndex.DataBind();
The tree expanded would look like
> Adult
- 2022
- 2021
- 2020
> Pediatric
- 2022
- 2021
- 2020
The databinding and expanding/collapsing is working fine
That I am trying to now do and figure out how best to do is to navigate and load a grid based upon the click of a year
So clicking on Adult or Pediatric Nodes would only expand or collapse the tree
Clicking on the Year node would then call an event that would pass in the population and the year and then load that grid (to the right of the tree) So for clicking on (Adult > 2021 ) node - was thinking navigating back to the page witth these values set, the tree expanded to show the selected node and the grid populated to display the records for population = adult and year = 2021
I was thinking I would add the event to the NodeDataBound
protected void radTVI_click(object sender, RadTreeNodeEventArgs e)
{
if (string.IsNullOrEmpty(e.Node.NavigateUrl))
e.Node.Attributes["onclick"] = "return Redirect(https://myjunkurl.com);";
}
And then work with it to basically ignore or only have expand or collapse on the clicks of Adult or Pediatric but otherwise generate the URL to call the page and pass in the SPop and Year to then load the tree and grid.
