Autopostback and validation

12 posts, 0 answers
  1. Fit2Page
    Fit2Page avatar
    468 posts
    Member since:
    Feb 2007

    Posted 13 Mar 2019 Link to this post

    Hi,

     

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

     

    TIA, Marc

  2. Rumen
    Admin
    Rumen avatar
    14466 posts

    Posted 18 Mar 2019 Link to this post

    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.
  3. konnyaku
    konnyaku avatar
    7 posts
    Member since:
    Jul 2018

    Posted 11 Apr 2019 in reply to Rumen Link to this post

    Unrelated, but its regarding the sample given. When I postback the form. how do I get which nodes is checked from the server side?
  4. Rumen
    Admin
    Rumen avatar
    14466 posts

    Posted 16 Apr 2019 Link to this post

    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.
  5. konnyaku
    konnyaku avatar
    7 posts
    Member since:
    Jul 2018

    Posted 10 May 2019 in reply to Rumen Link to this post

    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?

  6. Rumen
    Admin
    Rumen avatar
    14466 posts

    Posted 10 May 2019 Link to this post

    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.
  7. konnyaku
    konnyaku avatar
    7 posts
    Member since:
    Jul 2018

    Posted 13 May 2019 in reply to Rumen Link to this post

    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?

  8. Rumen
    Admin
    Rumen avatar
    14466 posts

    Posted 16 May 2019 Link to this post

    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.
  9. konnyaku
    konnyaku avatar
    7 posts
    Member since:
    Jul 2018

    Posted 23 May 2019 in reply to Rumen Link to this post

    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

  10. Rumen
    Admin
    Rumen avatar
    14466 posts

    Posted 29 May 2019 Link to this post

    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.
  11. konnyaku
    konnyaku avatar
    7 posts
    Member since:
    Jul 2018

    Posted 29 May 2019 in reply to Rumen Link to this post

    Tried, but the subnode.Checked.ToString() value is never True.
  12. Rumen
    Admin
    Rumen avatar
    14466 posts

    Posted 03 Jun 2019 Link to this post

    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.
Back to Top