Problem clearing values in table

4 posts, 0 answers
  1. cyfirst
    cyfirst avatar
    11 posts
    Member since:
    Sep 2009

    Posted 18 Dec 2009 Link to this post

    Hi,
    I'm having a problem clearing the values within a table and hoped for some input.  I have a table with values that can be entered by the user.  I also have a clear button, that when clicked executes javascript to set the value to "".  I've added a RadAjaxManager proxy to update the table when the clear button is clicked.  My problem is that the whole table disappears not just the values.  Can you tell me what I am doing wrong? 

    <

     

    asp:Table ID="IndexTable" runat="server" EnableViewState="false" >

     

     

    </asp:Table>

     

     

    <

     

    asp:Button ID="btnClear" runat="server" Text="Clear" Width="85px"

     

     

        style="text-align:center;vertical-align:middle;margin-left:10px" 

     

        OnClientClick="ClearIndexData();" />  

     

    <

     

    telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

     

    <script type="text/javascript" >

     

    function ClearIndexData() {  

     

          
                //repository  
                repo = document.getElementById("ctl00_MainContent_hfRepoHint").innerText;  
     
                //custom indexes  
                for (i = 1; i <= 20; i++) {  
                    if (document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "S") != null) {  
                        if (repo.charAt(0) == '5')  
                            document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "S").value = "";  
                        else  
                            document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "S").value = "";  
     
     
                    }  
                    else if (document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "R") != null) {  
                        if (repo.charAt(0) == '5')  
                            document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "R").value = "";  
                        else  
                            document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "R").value = "";  
     
                    }  
                }  
            } 

     

    </script>
    </telerik:RadScriptBlock>

     

     

     

     


    And here is the RadAjaxManager proxy settings
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
     <AjaxSettings> 
         <telerik:AjaxSetting AjaxControlID="btnClear">  
             <UpdatedControls> 
                 <telerik:AjaxUpdatedControl ControlID="IndexTable" /> 
             </UpdatedControls> 
         </telerik:AjaxSetting> 
     </AjaxSettings> 
    </telerik:RadAjaxManagerProxy> 
    Thanks in advance for any advice you can give me.
    Chris
  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 23 Dec 2009 Link to this post

    Hello Cyfirst,

    Please modify your Button as shown below:
    <asp:Button ID="btnClear" runat="server" Text="Clear" Width="85px" Style="text-align: center; vertical-align: middle; margin-left: 10px" OnClientClick="ClearIndexData(); return false;" />

    I hope this helps.

    Kind regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. cyfirst
    cyfirst avatar
    11 posts
    Member since:
    Sep 2009

    Posted 23 Dec 2009 Link to this post

    Hi Daniel,
    I tried that but it does not update the table then and the values are not cleared out.  I can do it via server code and rebuild the table but since I am only clearing the values, I thought it would be more efficient to just set value to "" via client script.  Any idea why the value would not be updated? 
    Thanks,
  4. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 30 Dec 2009 Link to this post

    Hello Chris,

    If I understand your scenario properly, the Table is created dynamically in code-behind. Please note that, in such cases, you should recreate the Table on each postback.

    Let me know if I'm missing something.

    Kind regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top