Aggregation

Posted by Giorgi Kviraia on 21-Mar-2017 06:25

hello all, i'm  looking at some tutorials and examples over this page and telerik docs page to see how does aggregation work, it gave me imaginaiton how should my example base col should aggregate, but after trying different way none of them has worked for me, maybe anyone here has any code example or any document how to achieve aggregation in kendo ui builder 1.1? i want to calculate average, sum, max, min of particular column, in one column , maybe calculate same way in 2 columns, make substraction and addition between 2 columns etc. 

Posted by Ricardo Perdigao on 21-Mar-2017 11:09

Hi Giorgi,

Here is a resource that might be helpful:

[View:http://demos.telerik.com/kendo-ui/grid/aggregates:550:50]

I've created a sample for you using the Customer table on the Sports2000 Database. Here is the steps I've followed:

========= Created a Grid for Customer using a blank view =========

  • Created a REST Service for Customer in the Sports2000 database (PDSOE)
  • Created a DataSource in KUIB to access my Service
  • Created a View using the Blank Template on KUIB 1.1
  • Created a DataSource called customerDS and pointed to Customer data
  • Created a Grid called customerGrid and linked customerDS to it

=======================================================

============ Implement Aggregate on view-factory.js ============

onShow: function($scope, customData) {
	this.scope = $scope;
	
	// Aggregate the value of CreditLimit for min and max
	$scope._$ds['customerDS'].aggregate([{ field: "CreditLimit", aggregate: "min" },
										 { field: "CreditLimit", aggregate: "max" }
										]);
	
	// Change the template on a single column on the Grid to display aggregates for CreditLimit
	for (var i = 0; i < this.scope.customerGrid.options.columns.length; i++) {
		if (this.scope.customerGrid.options.columns[i].field == 'CreditLimit') {
			this.scope.customerGrid.options.columns[i].aggregates = '["min", "max"]';
			this.scope.customerGrid.options.columns[i].footerTemplate = '<div>Min: #= min #</div><div>Max: #= max #</div>';
		}
	}					
},

=======================================================


I don't know how familiar you are with KUIB 1.1, so it is hard for me to know how much detail you will need. Please let me know if you need further explanation on the sample above.

Warm Regards,

Ricardo Perdigao

All Replies

Posted by Ricardo Perdigao on 21-Mar-2017 11:09

Hi Giorgi,

Here is a resource that might be helpful:

[View:http://demos.telerik.com/kendo-ui/grid/aggregates:550:50]

I've created a sample for you using the Customer table on the Sports2000 Database. Here is the steps I've followed:

========= Created a Grid for Customer using a blank view =========

  • Created a REST Service for Customer in the Sports2000 database (PDSOE)
  • Created a DataSource in KUIB to access my Service
  • Created a View using the Blank Template on KUIB 1.1
  • Created a DataSource called customerDS and pointed to Customer data
  • Created a Grid called customerGrid and linked customerDS to it

=======================================================

============ Implement Aggregate on view-factory.js ============

onShow: function($scope, customData) {
	this.scope = $scope;
	
	// Aggregate the value of CreditLimit for min and max
	$scope._$ds['customerDS'].aggregate([{ field: "CreditLimit", aggregate: "min" },
										 { field: "CreditLimit", aggregate: "max" }
										]);
	
	// Change the template on a single column on the Grid to display aggregates for CreditLimit
	for (var i = 0; i < this.scope.customerGrid.options.columns.length; i++) {
		if (this.scope.customerGrid.options.columns[i].field == 'CreditLimit') {
			this.scope.customerGrid.options.columns[i].aggregates = '["min", "max"]';
			this.scope.customerGrid.options.columns[i].footerTemplate = '<div>Min: #= min #</div><div>Max: #= max #</div>';
		}
	}					
},

=======================================================


I don't know how familiar you are with KUIB 1.1, so it is hard for me to know how much detail you will need. Please let me know if you need further explanation on the sample above.

Warm Regards,

Ricardo Perdigao

Posted by Giorgi Kviraia on 22-Mar-2017 04:45

Hello Ricardo Perdigao, i'm quite familiar with kuib 1,1 and blank view, working around it 3-4 month, your example looks awesome and ill try it right a head, i got another question, i see you aggregated min and max, is there any built in function for average, for subtraction and addition? same way as you did min and max ?

Posted by Giorgi Kviraia on 22-Mar-2017 05:01

works perfectly, thanks a lot. now for example if i need to find out average of column, which is populated with different number how can i achieve it?

example :  N1 tonnage is 500

                   N2 tonnage is 1000;

                average have to be 750;

                max is 1000;

                min is 500;

                total is 1500;

in one column or in between 2 columns.

Posted by Giorgi Kviraia on 22-Mar-2017 06:47

i can answer my own question above, managed to calculate. 

but what if i want to calculate salary of all employees in firm for one month, or for 3 month.?

Posted by Ricardo Perdigao on 22-Mar-2017 13:16

Hi Giorgi,

I am not sure I will have the time to write that sample for you ... But I would start by looking what this Kendo sample below does and try to adapt it to Kendo UI Builder.

dojo.telerik.com/.../InItU

Warm Regards,

Ricardo

Posted by Giorgi Kviraia on 23-Mar-2017 02:29

thanks a lot for your time and support Ricardo

This thread is closed