Refresh footer values in RadGrid client-side using RadNumericTextBox

Thread is closed for posting
2 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 14 Aug 2007 Link to this post

    Requirements

    RadGrid    
    RadInput    

    4.5.x+
    2.0.x+

    Web.UI version 2007.3.1425
    .NET version

    2.x

    Visual Studio version

    2005

    browser support

    all browsers supported by RadControls

    To convert code Telerik online converter

     
    PROJECT DESCRIPTION

    The code sample demonstrates how to use JavaScript and RadNumericTextBoxes to dynamically update the contents of a RadNumericTextBox, located in the footer of RadGrid. The code takes advantage of the Client-side API of the NumericTextBox control to update the footer control when onblur event is raised for RadNumericTextBox:

    JavaScript:

        <script type="text/javascript">  
           
          var sumInput = null;  
          var tempValue = 0.0;  
            
          function Load(sender, args)  
          {  
            sumInput = sender;  
          }  
          function Blur(sender, args)  
          {    
            sumInput.SetValue(tempValue + sender.GetValue());        
          }  
          function Focus(sender, args)  
          {  
            tempValue = sumInput.GetValue() - sender.GetValue();  
          }        
        </script> 

    ASPX:

            <radG:RadGrid ShowFooter="true" ID="RadGrid1" runat="server" DataSourceID="AccessDataSource1" 
                GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" Skin="Lime" AllowPaging="true" PageSize="15">  
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" DataSourceID="AccessDataSource1">  
                    <Columns> 
                        <radG:GridBoundColumn DataField="OrderID" DataType="System.Int32" HeaderText="OrderID" 
                            ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">  
                        </radG:GridBoundColumn> 
                        <radG:GridBoundColumn DataField="ShippedDate" HeaderText="ShippedDate" SortExpression="ShippedDate" 
                            UniqueName="ShippedDate" DataFormatString="{0:D}">  
                        </radG:GridBoundColumn> 
                        <radG:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" SortExpression="ShipCity" 
                            UniqueName="ShipCity">  
                        </radG:GridBoundColumn> 
                        <radG:GridTemplateColumn UniqueName="Template1" HeaderText="Freight">  
                            <ItemTemplate> 
                                <radI:RadNumericTextBox ID="TextBox1" runat="server" Text='<% #Eval("Freight") %>'>  
                                    <ClientEvents OnBlur="Blur" OnFocus="Focus" /> 
                                </radI:RadNumericTextBox> 
                            </ItemTemplate> 
                            <FooterTemplate> 
                                <radI:RadNumericTextBox ID="TextBox2" runat="server">  
                                    <ClientEvents OnLoad="Load" /> 
                                </radI:RadNumericTextBox> 
                            </FooterTemplate> 
                        </radG:GridTemplateColumn> 
                    </Columns> 
                    <PagerStyle Mode="NextPrevAndNumeric" /> 
                </MasterTableView> 
            </radG:RadGrid><asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb" 
                SelectCommand="SELECT [OrderID], [ShippedDate], [ShipCity], [Freight] FROM [Orders]"></asp:AccessDataSource> 

    VB:

    Private sum As Double = 0  
     
     
    Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As GridItemEventArgs) Handles RadGrid1.ItemDataBound  
        If TypeOf e.Item Is GridDataItem Then 
            Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem)  
            sum += Double.Parse((TryCast(dataItem("Template1").FindControl("TextBox1"), RadNumericTextBox)).Text)  
    ElseIf TypeOf e.Item Is GridFooterItem Then 
            Dim footer As GridFooterItem = DirectCast(e.Item, GridFooterItem)  
            footer("ShipCity").Controls.Add(New LiteralControl("<span style='color: white; font-weight: bold;'>Total freight on this page is:</span> "))  
            (TryCast(footer("Template1").FindControl("TextBox2"), RadNumericTextBox)).Text = sum.ToString()  
        End If 
    End Sub 
  2. 3BD6F94B-4C03-46D3-8568-9982F1F201BF
    3BD6F94B-4C03-46D3-8568-9982F1F201BF avatar
    10940 posts
    Member since:
    May 2014

    Posted 08 Mar 2008 Link to this post

    Hi guys,

    We've attached a Web.UI version of this project with small changes to the client API based on MS AJAX.

    Best wishes,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.