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

Get sum and average of selected items of a grid in alert / Field / popup

2 Answers 580 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shashank
Top achievements
Rank 1
Shashank asked on 19 Feb 2018, 05:24 AM

Hi, 

I am having a requirement to get sum and average of selected items (cells of specific numeric columns) of a grid in either an alert , Field or popup

Such as in the below example I want to get the average and Sum of selected Frieght columns

eg: https://demos.telerik.com/aspnet-mvc/grid/selection

I am not able to find the event for selectable: "multiple cell"

And also I want to allow this feature only on numeric fields. Please suggest the possible solution for this.

 

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 20 Feb 2018, 11:52 AM
Hello, Shashank,

The desired result can be achieved using the change event, select and the dataItem methods to get the value of the selected cells. Then a column index can be used to get the selected column:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/events/change#change

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/select

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/dataitem

I made an example demonstrating this:

https://dojo.telerik.com/IqavuW

Please have in mind that the Grid selection can be made over every cell, and if the selection has to be restricted the developer have to programmatically remove the k-state-selected class from all cell that should not be selected.

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Shashank
Top achievements
Rank 1
answered on 20 Feb 2018, 12:26 PM

Thanks Stefan for the solution. It worked !! 

 

Tags
Grid
Asked by
Shashank
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Shashank
Top achievements
Rank 1
Share this question
or