Hi all,
I would like to manage 4 checkbox in my radtreeview.
Here's the code :
<telerik:RadTreeView ID="rtv" Height="250px" Width="350px" BorderStyle="Solid" BorderWidth="2px" BorderColor="Black" runat="server"
Font-Names="Calibri" Font-Size="10px" CheckBoxes="true" CheckChildNodes="true" TriStateCheckBoxes="True">
<NodeTemplate>
<asp:Label ID="lbl_equipe" Width="100px" Font-Size="10px" runat="server"><%# DataBinder.Eval(Container.DataItem, "EQUIPE")%></asp:Label>
<asp:CheckBox onclick="return false;" Text="I" Font-Size="8px" TextAlign="Left" Checked="false" ID="primo_operatore" runat="server"/>
<asp:CheckBox onclick="return false;" Text="II" Font-Size="8px" TextAlign="Left" ID="secondo_operatore" runat="server"/>
<asp:CheckBox onclick="return false;" Text="III" Font-Size="8px" TextAlign="Left" ID="terzo_operatore" runat="server"/>
</NodeTemplate>
</telerik:RadTreeView>
One checkbox is the built-in checkbox (CheckBoxes="true")
The other three cbx are inside nodetemplate.
I want to achieve two goals :
1. When user check (uncheck) the native checkbox the remaining three are checked (unchecked) goal achieved
2. When user check/uncheck one of the three template checkboxes nothing should happen..problem
I use the nodecheck event handler to get first goal (in code behind)
This event fires not just for the native checkbox but even for the remaining three!
How can I distinguish the element in order to prevent the nodecheck event for the template checkboxes and let it fire for the single
one ?
I've tried in code behind inside the event routine but the e.node is referred to the whole nodetemplate and I can't get the single elements in.
Here's my code:
Private Sub rtv_NodeCheck(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles rtv.NodeCheck
Dim chk1 As CheckBox = DirectCast(e.Node.FindControl("primo_operatore"), CheckBox)
Dim chk2 As CheckBox = DirectCast(e.Node.FindControl("secondo_operatore"), CheckBox)
Dim chk3 As CheckBox = DirectCast(e.Node.FindControl("terzo_operatore"), CheckBox)
'Code to prevent the event if sender is one of three checkbox NodeCheck
' (??????????????????????????????????)
If e.Node.Level <> 1 Then Exit Sub 'event just for level 1 nodes
'parent nodes loop
For Each nd As RadTreeNode In rtv.Nodes
'When parent node is checked then start looping through all parent nodes looking for same nodetext
'If same node text is found then its checkbox is checked
If e.Node.Checked = True Then
'Enable node-template checkboxes
DirectCast(e.Node.FindControl("primo_operatore"), CheckBox).Checked = True
DirectCast(e.Node.FindControl("secondo_operatore"), CheckBox).Checked = True
DirectCast(e.Node.FindControl("terzo_operatore"), CheckBox).Checked = True
'Child nodes loop
For Each sub_nd As RadTreeNode In nd.Nodes
If sub_nd.Checked = False Then
Dim txt As String = sub_nd.Text
If txt = e.Node.Text Then 'Node text comparison
sub_nd.Checked = True
sub_nd.ParentNode.Expanded = True
'For each parent node checked the checkboxes inside template-childnode are checked
DirectCast(sub_nd.FindControl("primo_operatore"), CheckBox).Checked = True
DirectCast(sub_nd.FindControl("secondo_operatore"), CheckBox).Checked = True
DirectCast(sub_nd.FindControl("terzo_operatore"), CheckBox).Checked = True
End If
End If
Next
Else
'When parent node is unchecked then start looping through all parent nodes looking for same nodetext
'If same node text is found then its checkbox is unchecked
'Disable node-template checkboxes
DirectCast(e.Node.FindControl("primo_operatore"), CheckBox).Checked = False
DirectCast(e.Node.FindControl("secondo_operatore"), CheckBox).Checked = False
DirectCast(e.Node.FindControl("terzo_operatore"), CheckBox).Checked = False
'Child nodes loop
For Each sub_nd As RadTreeNode In nd.Nodes
If sub_nd.Checked = True Then
Dim txt As String = sub_nd.Text
If txt = e.Node.Text Then
sub_nd.Checked = False
sub_nd.ParentNode.Expanded = False
'For each parent node unchecked the checkboxes inside template-childnode are unchecked
DirectCast(sub_nd.FindControl("primo_operatore"), CheckBox).Checked = False
DirectCast(sub_nd.FindControl("secondo_operatore"), CheckBox).Checked = False
DirectCast(sub_nd.FindControl("terzo_operatore"), CheckBox).Checked = False
End If
End If
Next
End If
Next
End Sub
English is not my language, hope I was understandable.
Thanks in advance
GZ
I would like to manage 4 checkbox in my radtreeview.
Here's the code :
<telerik:RadTreeView ID="rtv" Height="250px" Width="350px" BorderStyle="Solid" BorderWidth="2px" BorderColor="Black" runat="server"
Font-Names="Calibri" Font-Size="10px" CheckBoxes="true" CheckChildNodes="true" TriStateCheckBoxes="True">
<NodeTemplate>
<asp:Label ID="lbl_equipe" Width="100px" Font-Size="10px" runat="server"><%# DataBinder.Eval(Container.DataItem, "EQUIPE")%></asp:Label>
<asp:CheckBox onclick="return false;" Text="I" Font-Size="8px" TextAlign="Left" Checked="false" ID="primo_operatore" runat="server"/>
<asp:CheckBox onclick="return false;" Text="II" Font-Size="8px" TextAlign="Left" ID="secondo_operatore" runat="server"/>
<asp:CheckBox onclick="return false;" Text="III" Font-Size="8px" TextAlign="Left" ID="terzo_operatore" runat="server"/>
</NodeTemplate>
</telerik:RadTreeView>
One checkbox is the built-in checkbox (CheckBoxes="true")
The other three cbx are inside nodetemplate.
I want to achieve two goals :
1. When user check (uncheck) the native checkbox the remaining three are checked (unchecked) goal achieved
2. When user check/uncheck one of the three template checkboxes nothing should happen..problem
I use the nodecheck event handler to get first goal (in code behind)
This event fires not just for the native checkbox but even for the remaining three!
How can I distinguish the element in order to prevent the nodecheck event for the template checkboxes and let it fire for the single
one ?
I've tried in code behind inside the event routine but the e.node is referred to the whole nodetemplate and I can't get the single elements in.
Here's my code:
Private Sub rtv_NodeCheck(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles rtv.NodeCheck
Dim chk1 As CheckBox = DirectCast(e.Node.FindControl("primo_operatore"), CheckBox)
Dim chk2 As CheckBox = DirectCast(e.Node.FindControl("secondo_operatore"), CheckBox)
Dim chk3 As CheckBox = DirectCast(e.Node.FindControl("terzo_operatore"), CheckBox)
'Code to prevent the event if sender is one of three checkbox NodeCheck
' (??????????????????????????????????)
If e.Node.Level <> 1 Then Exit Sub 'event just for level 1 nodes
'parent nodes loop
For Each nd As RadTreeNode In rtv.Nodes
'When parent node is checked then start looping through all parent nodes looking for same nodetext
'If same node text is found then its checkbox is checked
If e.Node.Checked = True Then
'Enable node-template checkboxes
DirectCast(e.Node.FindControl("primo_operatore"), CheckBox).Checked = True
DirectCast(e.Node.FindControl("secondo_operatore"), CheckBox).Checked = True
DirectCast(e.Node.FindControl("terzo_operatore"), CheckBox).Checked = True
'Child nodes loop
For Each sub_nd As RadTreeNode In nd.Nodes
If sub_nd.Checked = False Then
Dim txt As String = sub_nd.Text
If txt = e.Node.Text Then 'Node text comparison
sub_nd.Checked = True
sub_nd.ParentNode.Expanded = True
'For each parent node checked the checkboxes inside template-childnode are checked
DirectCast(sub_nd.FindControl("primo_operatore"), CheckBox).Checked = True
DirectCast(sub_nd.FindControl("secondo_operatore"), CheckBox).Checked = True
DirectCast(sub_nd.FindControl("terzo_operatore"), CheckBox).Checked = True
End If
End If
Next
Else
'When parent node is unchecked then start looping through all parent nodes looking for same nodetext
'If same node text is found then its checkbox is unchecked
'Disable node-template checkboxes
DirectCast(e.Node.FindControl("primo_operatore"), CheckBox).Checked = False
DirectCast(e.Node.FindControl("secondo_operatore"), CheckBox).Checked = False
DirectCast(e.Node.FindControl("terzo_operatore"), CheckBox).Checked = False
'Child nodes loop
For Each sub_nd As RadTreeNode In nd.Nodes
If sub_nd.Checked = True Then
Dim txt As String = sub_nd.Text
If txt = e.Node.Text Then
sub_nd.Checked = False
sub_nd.ParentNode.Expanded = False
'For each parent node unchecked the checkboxes inside template-childnode are unchecked
DirectCast(sub_nd.FindControl("primo_operatore"), CheckBox).Checked = False
DirectCast(sub_nd.FindControl("secondo_operatore"), CheckBox).Checked = False
DirectCast(sub_nd.FindControl("terzo_operatore"), CheckBox).Checked = False
End If
End If
Next
End If
Next
End Sub
English is not my language, hope I was understandable.
Thanks in advance
GZ