Hi,
I am completely new to telerik... We are about to buy but I am having some troubles to get started ..
I try to bind the treeview to the following structure:
- Assessment
- Folder
- Folder
....
- Assessment
(assessment is an own domain object and folder too)
I am getting all assessment as a list<Assessment> and those can contain 0-n folders. I tried to bind the treeview to the assessments and call the assessments Folders property within NodeDataBound.
Thats the page_load:
And then the nodedatabound:
The problem is that the ELSE IF part is never called ... and thus the sub folders of the folders are not rendered.
Any assistance would be appreciated as I am stuck here.. Not even sure if the approach is correct.
Thanks!!
I am completely new to telerik... We are about to buy but I am having some troubles to get started ..
I try to bind the treeview to the following structure:
- Assessment
- Folder
- Folder
....
- Assessment
(assessment is an own domain object and folder too)
I am getting all assessment as a list<Assessment> and those can contain 0-n folders. I tried to bind the treeview to the assessments and call the assessments Folders property within NodeDataBound.
Thats the page_load:
protected void Page_Load(object sender, EventArgs e) { |
if (!IsPostBack) { |
RadTreeView1.DataSource = new NHibernateDaoFactory().GetTagGroupDao().GetAll(); |
RadTreeView1.DataBind(); |
RadTreeNode untaggedNode = new RadTreeNode(GetLocalResourceObject("res_untagged").ToString(), ""); |
untaggedNode.AllowDrag = true; |
untaggedNode.Checkable = true; |
RadTreeView1.Nodes.Add(untaggedNode); |
uxTreeAssessments.DataSource = new NHibernateDaoFactory().GetAssessmentDao().GetAll(); |
uxTreeAssessments.DataFieldID = "ID"; |
uxTreeAssessments.DataValueField = "ID"; |
uxTreeAssessments.DataTextField = "LocalizedName"; |
uxTreeAssessments.DataBind(); |
} |
} |
And then the nodedatabound:
protected void uxTreeAssessments_NodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e) { |
if (e.Node.Level == 0) { |
Assessment a = e.Node.DataItem as Assessment; |
foreach (Folder f in a.Folders) { |
RadTreeNode n = new RadTreeNode( |
string.Format("{0} ({1})", f.LocalizedName, f.Questions.Count), |
f.ID.ToString()); |
n.DataItem = f; |
e.Node.Nodes.Add(n); |
} |
} else if (e.Node.Level > 0) { |
Folder parent = e.Node.DataItem as Folder; |
foreach (Folder f in parent.Folders) { |
RadTreeNode n = new RadTreeNode( |
string.Format("{0} ({1})", f.LocalizedName, f.Questions.Count), |
f.ID.ToString()); |
n.DataItem = f; |
e.Node.Nodes.Add(n); |
} |
} |
} |
The problem is that the ELSE IF part is never called ... and thus the sub folders of the folders are not rendered.
Any assistance would be appreciated as I am stuck here.. Not even sure if the approach is correct.
Thanks!!