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?!