This is a migrated thread and some comments may be shown as answers.
Kendo MVC Grid : How to create new column and its value is multiply of 2 other columns
2 Answers 128 Views
This is a migrated thread and some comments may be shown as answers.
Pham
Top achievements
Rank 1
Pham asked on 04 Jun 2015, 11:45 AM

Hello Telerik team

 I use Kendo MVC grid. My grid "Price", "Quantity" column. I want to add one more column "Total (Price*Quantity)" column. "Total (Price*Quantity)" column

 = "Price"*"Quantity".

- I don't want to generate "Total (Price*Quantity)" column in .

-  How to use Aggregates to create "Total (Price*Quantity)" column in

Thanks and Best regards

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 08 Jun 2015, 07:11 AM
Hi Pham,

The simplest approach would be to use a column template in which the calculation is done. This approach however will not allow you to perform any aggregations, because the calculation is done each time the Grid is redrawn and the  "Total (Price*Quantity)"  does not really exist in the DataSource. Another approach you might use is generating the field in the DataSource's schema.parse function.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Pham
Top achievements
Rank 1
answered on 08 Jun 2015, 01:01 PM

I solved it. This is my solution 

columns.Template(c => c.Quantity * c.Price).Title("Total (Price*Quantity)").ClientTemplate("#: Quantity*Price #");

Thank you.

Tags
Grid
Asked by
Pham
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Pham
Top achievements
Rank 1
Share this question
or