This is a migrated thread and some comments may be shown as answers.

Client side help - value of grid in separate control

2 Answers 122 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Laura asked on 25 Sep 2008, 03:09 PM
I have gotten so much help from this forum so far, and hope someone can help
me with my current situation.

I have a grid. In the grid I have a few column, mostly template columns.
They are User, email, address, package, and price.

In the edit/insert form is where most of the templates are. The edit
template items are a textbox not bound to the database, a label
not bound to the database, and 2 embedded grids. The first embedded
grid has a price column which I hide and I want to take that vaule and
place it in the unbound textbox column.

The second embedded grid has a column of prices in a template column
of radnumerictextbox type. I want to take the values of this column,
add them up, and put them in the column of the edit form that I have
as a label in the template of the coluimn. And whenever a radnumeric
textbox gets changed, I want this label to change. I tried doing this
in C# codebehind, and it is not changing the column.

The values of the totals are being maintained in textboxes here:
 <asp:TextBox ID="TextBoxPackagePrice" runat="server" Visible="false"></asp:TextBox>
   <asp:TextBox ID="TextBoxTotalAlaCartePrice" runat="server" ></asp:TextBox>
   <asp:TextBox ID="TextBoxTotalPrice" runat="server" Visible="false"></asp:TextBox>

My column in the embedded grid for the radnumerictextbox is:
<telerik:GridTemplateColumn HeaderText="Price" UniqueName="Price" >
              <telerik:RadNumericTextBox  ID="RadNumericTextBox1" runat="server"
                       AutoPostBack="true" Price='<%# Eval("Price") %>'
                        Culture="English (United States)" Type="Currency" Value="0" Width="125px" 
                           EditFormColumnIndex="2"  >

How can do what I want on the client side using javascript to the add up  the
radnumerictextbox column to get a running total, and how can I take that
total and place in somewhere(in a template column label) in my edit form for
the outside grid? And when the radnumerictextbox changes, what is the clientside
call to update that label?

Hope I am making myself clear.
Thanks in advance,

2 Answers, 1 is accepted

Sort by
Telerik team
answered on 29 Sep 2008, 07:49 PM
Hi Laura,

You can find attached a sample project demonstrating the functionality you required. Please note the numeric textboxes we create. The totals box has its client-side OnLoad event hooked up, so that we can get a reference to it for all the other textboxes to use. The other two textboxes that we need to sum up have their OnFocus and OnBlur handlers attached. The OnFocus handler is used to save the previous value of the textbox to a hidden variable, so that we can subtract it from the total in the calculations made in the OnBlur event. The OnBlur event, in turn, simply calculates the total by subtracting the previous (or old) value of the textbox and adding its new value.

Please check this example out and see if it useful. The example demonstrates how an arbitrary number of textboxes can be set up to update a single totals textbox with minimum client code.

the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Top achievements
Rank 1
answered on 21 Oct 2008, 10:22 PM
Thank you. I used a modified version of your demonstration and was able to get it work client side.
I appreciate all your efforts to help.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Top achievements
Rank 1
Share this question