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

'sum is not defined' error on grid

3 Answers 672 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albana
Top achievements
Rank 1
Albana asked on 05 Jun 2012, 03:29 PM
Hi ,
I am developing an application using kendoui grid,and i am facing a problem
when grouping the records according  to different columns.
I want to have records grouped by name column and at the same time have footerTemplate and groupFooterTemplate for quantity  column.
When i add another column on grouping i get an error 'sum is not defined'.
I have looked around on kendo forums, and even the following forum topic:
http://www.kendoui.com/forums/ui/grid/groupable-aggregates-and-groupfootertemplate-problems.aspx

doesn't resolve me the problem.(which looks me more similar to my problem).
I am putting the columns,group,aggregates and fields using php variables:
$arr=array(array('field'=>'pol','title'=>'Part Number','width'=>'200px','aggregates'=> "count", 'groupHeaderTemplate'=> "Part Number: #=value#"),
     array('field'=>'name','title'=>'PO ','aggregates'=> "count", 'groupHeaderTemplate'=> "PO Teknema: #=value#"),
     array('field'=>'po_supp','title'=>'PO Supplier','aggregates'=> "count", 'groupHeaderTemplate'=> "PO Supplier: #=value#"),
     array('field'=>'seltc','title'=>'Quantity Received','aggregates'=> "count", 'groupHeaderTemplate'=> "Quantity Received: #=value#"),
     array('field'=>'pol_qty','title'=>'Qty to Receive','aggregates'=> "sum", 'footerTemplate'=> "Total Sum: #=sum#",'groupFooterTemplate'=> "Sum: #=sum#" ),
     array('field'=>'qty_purchased','title'=>'Total Qty','aggregates'=> "count", 'groupHeaderTemplate'=> "Total Qty: #=value#"),
     //array('field'=>'prod_name','title'=>'Part Number'),
     array('field'=>'rif_ordine','title'=>'Rif.Ordine','aggregates'=> "count", 'groupHeaderTemplate'=> "Rif.Ordine: #=value#"),
     array('field'=>'project','title'=>'Project','aggregates'=> "count", 'groupHeaderTemplate'=> "Project: #=value#"),
     array('field'=>'po_ref','title'=>'PO Reference','aggregates'=> "count", 'groupHeaderTemplate'=> "PO Reference: #=value#"),
  );
$columns=json_encode($arr);
$arr=array(
    'pol'=>array('type'=>'string'),
    'name'=>array('type'=>'string'),
    'po_supp'=>array('type'=>'string'),
    'seltc'=>array('type'=>'string'),
    'pol_qty'=>array('type'=>'number'),
    'qty_purchased'=>array('type'=>'number'),
    //'prod_name'=>array('type'=>'string'),
    'rif_ordine'=>array('type'=>'string'),
    'project'=>array('type'=>'string'),
    'po_ref'=>array('type'=>'string'),
     );
$fields=json_encode($arr);
$arr=array('field'=>'name',
    'aggregates'=>array(
        array('field'=>'pol','aggregate'=>'count'),
        array('field'=>'name','aggregate'=>'count'),
        array('field'=>'po_supp','aggregate'=>'count'),
        array('field'=>'seltc','aggregate'=>'count'),
        array('field'=>'pol_qty','aggregate'=>'sum'),
        array('field'=>'qty_purchased','aggregate'=>'count'),
        array('field'=>'rif_ordine','aggregate'=>'count'),
        array('field'=>'project','aggregate'=>'count'),
        array('field'=>'po_ref','aggregate'=>'count'),
        )
        );
$group=json_encode($arr);
$arr=array(
    array('field'=>'pol','aggregate'=>'count'),
    array('field'=>'po_supp','aggregate'=>'count'),
    array('field'=>'seltc','aggregate'=>'count'),
    array('field'=>'pol_qty','aggregate'=>'sum'),
    array('field'=>'qty_purchased','aggregate'=>'count'),
    array('field'=>'rif_ordine','aggregate'=>'count'),
    array('field'=>'project','aggregate'=>'count'),
    array('field'=>'po_ref','aggregate'=>'count'),
     );
$aggregate=json_encode($arr);

and then pass these variables on js 


Please Help me to solve the problem.
Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 25 Jun 2012, 02:32 AM
Is there any word on this or the referenced thread? It appears folks are having issues using Datasource + MVVM + Grid Aggregates + Empty List. The error (which the stack trace is deep in the call stack between Kendo code and jQuery calls) is '<Any_Agg_Func> is undefined'.

In my particular case, I am using a datasource, fetching from a database using ajax. The data rows are using the observable pattern (MVVM). And I have a Count aggregate configured for the first column (tho it doesn't matter which column nor aggregate func). Everything is great when there are rows - no errors and the footer row is shown.

However, in any case that results in the rows being empty, the above error is returned and processing halts. This can happen when the datasource is reading. This can happen after the last row is removed and then the sync method is called. I believe there is one more scenario too. This is a serious issue and trashing the entire application (unless I remove all footers which is a requirement so not an option).

I haven't included any code because it is all boiler-plate config. Does anyone have this working for them? And can Kendo Support respond to this?

Thanks!
Mike
0
Michael
Top achievements
Rank 1
answered on 25 Jun 2012, 03:22 AM
Update: The offending line where the error happens is on 18,974 of the kendo.web.js source file for the 601 dev build (tho happens since Q1 release). The line is: 
html = $(that._wrapFooter(footerTemplate(aggregates)));

To move toward a prod release for my app, I threw a try/catch around most of the code in this block (in the _footer function). Everything works as expected now, so at least I have a plan. However, I do not want to be editing source code. Please remedy.

Thanks,
Mike
0
Atanas Korchev
Telerik team
answered on 25 Jun 2012, 07:49 AM
Hi Michael,

 This issue will be fixed for the next official release of Kendo UI which is due in July.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Albana
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or