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

Autopostback and validation

11 Answers 437 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Fit2Page asked on 13 Mar 2019, 12:53 PM

Hi,

 

Is there an example available of how to validate the raddropdowntree in combination with AutoPostback = true?

 

TIA, Marc

11 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 18 Mar 2019, 02:03 PM
Hi Marc,

Please check the following live demo: Validation, which shows how to validate RadDropDownTree by the use of an asp:CustomValidator. In this case the page could be submitted only if something, that will change the default value of the control, is chosen from the RadDropDownTree. The validatePage() function attached to the ClientValidationFunction validator event checks the count of the entries collection of the DropDownTree and if it is 0, sets the args.IsValid to false.

The DropDownTree also works with all of the standard ASP.NET validators.

Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
konnyaku
Top achievements
Rank 1
answered on 12 Apr 2019, 04:49 AM
Unrelated, but its regarding the sample given. When I postback the form. how do I get which nodes is checked from the server side?
0
Rumen
Telerik team
answered on 16 Apr 2019, 03:02 PM
Hi Konnyaku,

For all checked nodes are created entries, which you can access in the Entries server collection of the control and get the needed information. Please also check and use the following server events.

Best regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
konnyaku
Top achievements
Rank 1
answered on 10 May 2019, 06:48 AM

Thank you for your reply. My design is quite different.

For each RadDropDownTree entries, I enable the checkbox.

When I click Submit button, I want to see which entry has been checked.

Is this possible to do using RadDropDownTree?

0
Rumen
Telerik team
answered on 10 May 2019, 02:17 PM
Hello Konnyaku,

You can obtain the entries client side by getting reference to the DropDownTree client-side object

var ddt = $find("ctl00_ContentPlaceholder1_RadDropDownTree1");

and get_entries() method, which returns the RadDropDownTree Entries collection:

ddt.get_entries()._array[0].get_text();
ddt.get_entries()._array[0].get_value();

Please see the attached image for more information.

Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
konnyaku
Top achievements
Rank 1
answered on 13 May 2019, 08:15 AM

Thank you for the quick reply.

Since the design involved postback, is there a way to check on the server side instead of client side?

0
Rumen
Telerik team
answered on 16 May 2019, 08:03 AM
Hi,

Check this article: Accessing the Embedded Tree - by having a reference to the treeview control you can use its server API to see which nodes are selected > 
RadDropDownTree1.EmbeddedTree.Nodes[0].Checked


Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
konnyaku
Top achievements
Rank 1
answered on 23 May 2019, 08:43 AM

I tested like this, not on Page_Load, but upon button click:

        For Each tree As RadTreeNode In RadDropDownTree1.EmbeddedTree.Nodes
            MsgBox(tree.Text + " " + tree.Checked.ToString())
        Next

It did not capture the checked/unchecked state of the RadDropDownTree1

0
Rumen
Telerik team
answered on 29 May 2019, 02:50 PM
Hello,

My advice is to make it working for a Button Click and after that in the page events:

ASPX
<telerik:RadDropDownTree RenderMode="Lightweight" ID="RadDropDownTree1" runat="server" Width="300px" CheckBoxes="SingleCheck"
                DefaultMessage="Please select" DataFieldID="EmployeeID" DataFieldParentID="ReportsTo" OnNodeDataBound="RadDropDownTree1_NodeDataBound"
                DataTextField="LastName" DataSourceID="SqlDataSource1">
                <DropDownSettings OpenDropDownOnLoad="true" />
            </telerik:RadDropDownTree>  
<asp:Button Text="ShowCheckedItems" runat="server" OnClick="Unnamed_Click" />
<asp:TextBox TextMode="MultiLine" Width="200px" Height="200px" runat="server" ID="MultiBox1"></asp:TextBox>


Codebehind:
Protected Sub Unnamed_Click(ByVal sender As Object, ByVal e As EventArgs)
    For Each node As RadTreeNode In RadDropDownTree1.EmbeddedTree.Nodes
 
        If node.GetAllNodes().Count <> 0 Then
 
            For Each subnode As RadTreeNode In node.GetAllNodes()
                checkedNode += subnode.Text & " " + subnode.Checked.ToString() & vbLf
                MultiBox1.Text = checkedNode
            Next
        End If
    Next
End Sub


Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
konnyaku
Top achievements
Rank 1
answered on 30 May 2019, 02:03 AM
Tried, but the subnode.Checked.ToString() value is never True.
0
Rumen
Telerik team
answered on 03 Jun 2019, 11:01 AM
On my side the solution works as expected. For your convenience I have attached my test files and a video demo.

Best Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DropDownTree
Asked by
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Rumen
Telerik team
konnyaku
Top achievements
Rank 1
Share this question
or