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

Aggregates error (Signature + ClassFactory)

2 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gusev
Top achievements
Rank 1
Gusev asked on 12 Sep 2017, 09:15 AM

Hello guys.

Unfortunately, I've found an error in Kendo (there is no such error in 2015.3.930.545 (just for information))
Check the example project. 
https://www.dropbox.com/s/7h8gm1ekyui56qq/KendoUI.rar?dl=0

Description:
 - I have two grids.
 - They both have a field "Volume" and calculate the sum of this field.
 - They don't have any other aggregates for other fields. (it's important)

What I have:
1) Static class "ClassFactory" ("~/Infrastructure/Implementation/ClassFactory.cs") which has a variable Dictionary<Signature, Type> classes.
2) Class "Signature" ("~/Infrastructure/Implementation/Signature.cs") that has a method "Equals"
3) ArgumentException

Description:
When one of grid sends a request to controller, some manipulations are performed and we find ourselves in "ClassFactory" in a method "GetDynamicClass". Here a variable (name - signature) of type "Signature" is added to the variable "classes" of type "Dictionary<Signature, Type>". No problems, everything is fine. Then another grid does the same steps. But now, when the variable "signature" is being added to the variable "classes", I get exception "ArgumentException". Why? Look at the code of the method "Equals" of the class 'Signature':

if (poperties.Length != other.properties.Length) return false;
for (int i = 0; i < properties.Length; i++)
{
    if (properties[i].Name != other.properties[i].Name || properties[i].Type != other.properties[i].Type) 
        return false;
}
return true;


Aggregates for the first grid: Sum_Volume for the field "Volume"
Aggregates for the second grid: Sum_Volume for the field "Volume"
Conclusion:
Aggregates are the same, so the method "Equals" returns true
And that's why I get "ArgumentException" (An item with the same key has already been added)

Solution:
People who have the same error:
You can:
1) Add the hidden field to the grid (to the model) and aggregate sth (for ex: sum) for this field. (if you have more than 2 grids with such problem, don't forget that these hidden fields must have different names, otherwise it won't help)
2) You can rename a field in one of the grids
3) Wait until Kendo fixes it :)
4) Maybe someone has another idea?!

2 Answers, 1 is accepted

Sort by
0
Gusev
Top achievements
Rank 1
answered on 12 Sep 2017, 09:27 AM

I've forgotten to say

  • kendo version that I use is "2017.2.621.545"  (but this one you would find out yourself without me)
  • if you uncomment //x.Add(s => s.SignatureClassEqualsMethodAdditinonalField).Sum(); in the example everything will work. (just a proof of my previous words)
0
Stefan
Telerik team
answered on 14 Sep 2017, 10:32 AM
Hello Gusev,

Thank you for the report and the example.

I logged this in our GitHub repository for additional investigations and fixing:

https://github.com/telerik/kendo-ui-core/issues/3582

Additionally, I updated your Telerik points for bringing this to our attention and providing a workaround of it.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Gusev
Top achievements
Rank 1
Answers by
Gusev
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or