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

How to auto aggregate column in javascript

9 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yvan
Top achievements
Rank 1
Yvan asked on 12 Jun 2008, 02:14 PM
Hi,
I have a grid where all the rows are in edit mode and a column with a total in the footer of the grid. I want to automatic display the sum of the column without postback when the user enter a value in a cell. The only solution to do this seems to be to sum the column in Javascript.  It is possible to do that ?  Is there a grid client API to do this?

Thanks
Yvan Sigouin

9 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 16 Jun 2008, 11:09 AM
Hi Yvan,

There is no "out-of-the-box" implementation of your desired functionality. Nevertheless, you can get the values of your cells on the client and sum them up in the "keypress" client event handler of your input. Please refer to this online help article on extracting key values client-side.

Regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Vlad
Telerik team
answered on 16 Jun 2008, 11:34 AM
Hi Yvan,

Just a quick follow up. I have created for you small example to illustrate you how to achieve this. You can find the example attached.

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Veli
Telerik team
answered on 16 Jun 2008, 11:44 AM
Hello Yvan,

Additionally, here is a sample online demo demonstrating recalculation of totals textbox on Blur event of the current edited textbox:

RadNumericTextBox for RadGrid Footer totals

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Yvan
Top achievements
Rank 1
answered on 17 Jun 2008, 12:38 PM
Hi,

Good! Now I have a grid with auto-calculate sum fields.
But I suggest to add this feature in the client API for the next release of RadGrid.

Thanks 

Yvan
0
Sebastian
Telerik team
answered on 17 Jun 2008, 12:43 PM
Hello Yvan,

Thank you for the suggestion - I will forward it to our development department for further consideration. If this appears to be a common request and a feasible addition to the current client object model of the grid, you may see it included in a future version of the product.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
newbie
Top achievements
Rank 1
answered on 29 Jul 2008, 12:39 AM
I tried to use the code provided in the sample.
The problem I have is , I have multiple columns in my grid for which I need to display the total.
With the code provided if i update any cell the total for all the columns gets updated to the same amount.

Can you provide me some code which meets my requirements.
That is update the total in the respective column in which the cell belongs.

I have been struggling with various ways to auto update the aggregate on client side but always end up running into some kinds of issues.

Please help.
0
Sebastian
Telerik team
answered on 29 Jul 2008, 06:24 AM
Hello newbie,

The javascript logic for updating the footer values for multiple columns will not differ if you ensure that you access the cells of the column of interest using its unique name. Please verify that and let us know if further directions/assistance is needed.

Best,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
newbie
Top achievements
Rank 1
answered on 29 Jul 2008, 04:03 PM
can you provide me an example of that using the sample website that's referenced below?
0
Sebastian
Telerik team
answered on 30 Jul 2008, 11:52 AM
Hi newbie,

Here is the example you requested (you will find it attached to this message). Note that I added duplicate Freight column as last in the grid and attached different Blur/Focus/Load client handlers for the second set of RadNumericTextBox instances in that column.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Yvan
Top achievements
Rank 1
Answers by
Veli
Telerik team
Vlad
Telerik team
Yvan
Top achievements
Rank 1
Sebastian
Telerik team
newbie
Top achievements
Rank 1
Share this question
or