Community & Support
Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > General and Integration Projects > Refresh footer values in RadGrid client-side using RadNumericTextBox

Not answered Refresh footer values in RadGrid client-side using RadNumericTextBox

Feed from this thread
  • Posted on Aug 14, 2007 (permalink)

    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 

  • Steve Steve admin's avatar

    Posted on Mar 8, 2008 (permalink)

    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
    Attached files

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET and ASP.NET AJAX > General and Integration Projects > Refresh footer values in RadGrid client-side using RadNumericTextBox