One checked node javascript problem

6 posts, 1 answers
  1. Christian
    Christian avatar
    64 posts
    Member since:
    Apr 2008

    Posted 24 Feb 2011 Link to this post

    Hi,

    I have a treeview inside a combobox, and i have hooked up a javasript that uncheckes any previus nodes, according to this article,
    http://www.telerik.com/help/aspnet/treeview/tree_unchecknodebycheckinganothernode.html

    But i cant get the script working, could it be becouse of the treeview being inside of a panelbar and/or a combobox, and if so, would anyone have a solution for this?

    <asp:Content ID="Content3" ContentPlaceHolderID="phContent" Runat="Server">
    <script type="text/javascript" language="javascript">
       var oldNode;
       function UpdateStatus(node)
       {
           if(oldNode != null)
           {
           oldNode.UnCheck();
           }
           node.Check();
           oldNode = node;
       }
    </script>
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        </telerik:RadAjaxManagerProxy>
          
        <table cellspacing="0" width="100%">
      
    <%--
    Om man är inloggad som Admin ska man komma direkt till Steg 2
    --%>
    <tr align="center">
    <td align="center" style="padding-top:100px;">
        <telerik:RadPanelBar ID="pbCaseRegistration" Runat="server" Skin="Windows7" 
            Width="500px" ExpandMode="SingleExpandedItem">
            <Items>
                  
                <telerik:RadPanelItem runat="server" Text="1 - Ärendeinformation" Expanded="true">
                    <Items>
                        <telerik:RadPanelItem runat="server" Value="panCaseinfo">
                            <ItemTemplate>
                                <table class="text" style="padding:10px;" cellspacing=0 width=100%>
                                <tr>
                                <td align=center>
                                    <asp:Image ID="imgCaseType" runat="server" ImageUrl="images/infoIcon2.jpg" /><asp:Label ID="Label1" runat="server" Text="Ärendetyp"></asp:Label><br />
                                      
                                           <telerik:RadComboBox ID="cmbCaseType" runat="server" Skin="Windows7" Height="160px" Style="vertical-align: middle;" Width="225px">
                                                <ItemTemplate>
                                                    <div id="div1">
                                                      
                                                        <telerik:RadTreeView ID="tvCaseType" runat="server" CheckBoxes="True" 
                                                            Height="160px" Width="100%" AfterClientCheck="UpdateStatus">
                                                              
                                                        </telerik:RadTreeView>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Feb 2011 Link to this post

    Hello Christian,

    You can use OnClientNodeChecked property instead of AfterClientCheck:

    <telerik:RadTreeView ID="tvCaseType" runat="server" CheckBoxes="True"
     OnClientNodeChecked="UpdateStatus">

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Christian
    Christian avatar
    64 posts
    Member since:
    Apr 2008

    Posted 25 Feb 2011 Link to this post

    Hello Princy,

    thanks for the reply, i did change the event as you said and now the event is fired but i get a error when debugging that says
    "Microsoft JScript runtime error: Object doesn't support this property or method"

    on this line of code in the javascript

    <

     

    script type="text/javascript" language="javascript">

     

    var oldNode;

    function UpdateStatus(node)

    {

    if(oldNode != null)

    {

    oldNode.UnCheck();

    }

    node.Check();      <<<<---- error on this line.

    oldNode = node;

    }

    </

     

    script>

     



    if i choose continue i still get several checkboxes checked

  5. Christian
    Christian avatar
    64 posts
    Member since:
    Apr 2008

    Posted 25 Feb 2011 Link to this post

    I managed so solve all my issues using a custom validator script, so i tought i might share it here.

    <script type="text/javascript">    
        function ClientValidate(source, arguments) {
             var treeView = document.getElementById("ctl00_phContent_pbCaseRegistration_i0_i0_cmbCaseType_i0_tvCaseType");     
             var checkBoxes = treeView.getElementsByTagName("input");     
             var checkedCount = 0;     
             for (var i = 0; i < checkBoxes.length; i++)
             {       
                if (checkBoxes[i].checked) 
                {         
                    checkedCount++;       
                }     
             }     
             if (checkedCount > 0 && checkedCount < 2) 
             {       
             arguments.IsValid = true;     
             
             else 
             {       
             arguments.IsValid = false;     
             }   
         }          
    </script>

    <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ClientValidate" ErrorMessage="CustomValidator" Display="Dynamic" ValidationGroup="Step1">Vänligen ange En ärendetyp</asp:CustomValidator>

    My only concern right now is that i have a radpanel with 3 groups/panels, and in each panel i have a validatorn group thats checked when hitting a "next" button that checks all inputs in the first panel and enables and expands the second panel.

    But, when the button is fired it does a postback, leaving all values in the first panel empty again...
    So, would anyone know how i can validate a group using a button without doing a postback and enable and expand the second panel?
  6. Answer
    Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 01 Mar 2011 Link to this post

    Hi Christian,

    Instead of your custom validator, why don't you try the following implementation of the OnClientNodeChecking event handler function:
    function OnClientNodeChecking(sender, args) {
         
        sender.uncheckAllNodes();           
    }

    This way only one node will be checked at a time.

    Kind regards,
    Dimitar Terziev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  7. Christian
    Christian avatar
    64 posts
    Member since:
    Apr 2008

    Posted 01 Mar 2011 Link to this post

    thanks, dont know why i dident think of that one, you just saved my users some cpu load.

    If you have any spare time i have some problems at another thread,
    http://www.telerik.com/community/forums/aspnet-ajax/panelbar/3-step-panelbar-with-validaton-postback-issues.aspx

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017