Telerik
Home / Community / Forums / Grid / Grid / RadNumericTextBox for Footer Totals

Not answered Grid / RadNumericTextBox for Footer Totals

Feed from this thread
  • Zinoviy Margovskiy avatar

    Posted on Jul 2, 2009 (permalink)

    hi,

    I am trying to do something similar to the demo for Grid / RadNumericTextBox for Footer Totals (http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandinput/defaultcs.aspx?product=grid).

    However, my situation is a bit different.  I have a grid with template column like so:
    <telerik:GridTemplateColumn UniqueName="TotalCost" DataField="TotalCost" HeaderText="Total Cost"
        <ItemTemplate> 
            <telerik:RadNumericTextBox ID="litTotalCost" runat="server" Type="Currency"  
             Text='<%# decimal.Parse(Eval("Quantity").ToString()) * decimal.Parse(Eval("ListPrice").ToString()) %>'/>                                                                                        
            </ItemTemplate> 
            <EditItemTemplate> 
                <telerik:RadNumericTextBox ID="txtTotalCost" runat="server" Type="Currency" 
                    Text='<%# decimal.Parse(Eval("Quantity").ToString()) * decimal.Parse(Eval("ListPrice").ToString()) %>'
                    <ClientEvents OnBlur="txtTotalCost_OnBlur" OnFocus="txtTotalCost_OnFocus" /> 
                </telerik:RadNumericTextBox> 
            </EditItemTemplate> 
            <FooterTemplate> 
                <asp:Label ID="lblTotalCost" runat="server" Text="Total Cost:"></asp:Label>&nbsp: 
                    <telerik:RadNumericTextBox ID="txtGrossTotalCost" runat="server" Type="Currency"
                      <ClientEvents OnLoad="txtTotalCost_OnLoad" /> 
                    </telerik:RadNumericTextBox> 
            </FooterTemplate>                                                 
    </telerik:GridTemplateColumn>  

    And javascript as recomended in the demo:
    var sumInput = null
    var tempValue = 0.0 
     
    function txtTotalCost_OnLoad(sender, args)  
                sumInput = sender; 
    function txtTotalCost_OnBlur(sender, args)  
        sumInput.set_value(tempValue + sender.GetValue()); 
    }                                   
     
    function txtTotalCost_OnFocus(sender, args)  
        tempValue = sumInput.get_value() - sender.get_value(); 
     

    However, when grid is in Edit mode, in addition to modifying total value in the footer, I need to modify value in another cell of the edited row of the grid (which is also a text box in edit mode).  How can I access this other control and set its value inside  my  txtTotalCost_OnBlur function.


    Reply

  • Telerik Admin admin's avatar

    Posted on Jul 3, 2009 (permalink)

    Hello Zinoviy,

    In order to get access to the other textbox editor in the grid row, you can consider the approaches presented in the following code library threads on our site:

    http://www.telerik.com/community/code-library/aspnet-ajax/grid/accessing-server-controls-in-a-grid-template-on-the-client.aspx

    http://www.telerik.com/community/code-library/aspnet-ajax/grid/retrieving-grid-editor-value-client-side.aspx

    Thus you will be able to reference the input and change its value from within the OnBlur client event handler of the numeric textbox.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Zinoviy Margovskiy avatar

    Posted on Jul 8, 2009 (permalink)

    OK.  I think I figured out how to reference controls in edit mode on client.
    In my case I am running following code:

          var radGrid = $find('<%= RadGrid1.ClientID %>');
          if (radGrid._editIndexes[0])
          {
                    var editIndex = radGrid._editIndexes[0];
                    var row = radGrid.get_masterTableView().get_dataItems()[editIndex];
                    var cntrlTotalCost = row.findControl("txtTotalCost");
                  
                  //  Do something with the cntrlTotalCost  control
                  ........................
          }


    Now this works fine for edited rows, however it will not work for insert row. 
    How do I reference controls in Insert row on client?

    Reply

  • Telerik Admin admin's avatar

    Posted on Jul 9, 2009 (permalink)

    Hello Zinoviy,

    How to reference the controls inside the RadGrid insert form on the client you can see from this code library example.

    Kind regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Zinoviy Margovskiy avatar

    Posted on Jul 9, 2009 (permalink)

    Sebastian,
    I am already doing something similar to the example you pointed, however I hoped that there is a collection of inserted indexes/items like we have when editing or deleting rows: (radGrid._editIndexes/ radGrid._deletedItems), because I need to treat those controls in the insert row as Ajax controls vs. regular HTML DOM controls.  Other words I need those controls to have properties/methods of Ajax controls (set_value, get_value, etc..)  Is there a collection of inserted items on client that I can access and work with?



    Reply

  • Telerik Admin admin's avatar

    Posted on Jul 9, 2009 (permalink)

    Hello Zinoviy,

    There is no client object exposed that will represent the insertion item in the grid. However, you can use the global $telerik.findControl(container, controlId) method passing the table tr which represents the DOM element of the inserted item as first argument (container) to that method. Thus you should be able to reference other ASP.NET/AJAX controls in the insert form to operate with them.

    See this forum thread for more details:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/identifying-the-grid.aspx

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.