var
x =
new
kendo.data.DataSource({
data: [],
group: {
field:
"boo"
, aggregates: [
{ field:
"foo"
, aggregate:
"sum"
}
]
}
});
The above TypeScript code causes a compilation error with TypeScript definition of KendoUI (http://www.telerik.com/forums/q1'14-release---missing-typescript-definitions-70584e6883b0 ). Here is the error message:
Supplied parameters do not match any signature of call target:
Types of property 'group' of types '{ data: any[]; group: { field: string; aggregates: { field: string; aggregate: string; }[]; [n: number]: kendo.data.DataSourceGroupItem; }; }' and 'kendo.data.DataSourceOptions' are incompatible:
Type '{ field: string; aggregates: { field: string; aggregate: string; }[]; [n: number]: kendo.data.DataSourceGroupItem; }' is missing property 'concat' from type 'kendo.data.DataSourceGroupItem[]'.
5 Answers, 1 is accepted
0
Jeffrey
Top achievements
Rank 1
answered on 13 Aug 2014, 06:25 AM
I found the cause!
According to the document, group accepts array or object, but there is only the array definition in kendo.all.d.ts. So the workaround is to put the DataSourceGroupItem object in array:
According to the document, group accepts array or object, but there is only the array definition in kendo.all.d.ts. So the workaround is to put the DataSourceGroupItem object in array:
var
x =
new
kendo.data.DataSource({
data: [],
group: [ {
field:
"boo"
, aggregates: [
{ field:
"foo"
, aggregate:
"sum"
}
]
} ]
});
0
Hello Jeffrey,
Alex Gyoshev
Telerik
Indeed, in order to allow the object to be strongly-typed, we are declaring the group property as a DataSourceGroupItem[]. Otherwise, we would have to declare it of type any, which doesn't help much. Until there are union types in typescript, we would keep this as it is.
Regards,Alex Gyoshev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeffrey
Top achievements
Rank 1
answered on 17 Aug 2014, 08:23 AM
Agree, strong-typed DataSourceGroupItem[] is better than any. Thanks for information about union types, I think it's a import feature for Typescript to match JavaScript's practical behavior.
Regards,
Jeffrey
Regards,
Jeffrey
0
Sean
Top achievements
Rank 1
answered on 16 Jul 2015, 03:02 PM
I know this is a little old, but I just came across this issue as well and spent a fair amount of time investigating before I came across this post. I think the problem is that the Kendo documentation ​has examples of the datasource being initialized without the group object wrapped in an array (see the attached image)
Kendo folks, would it make sense to update the docs to include a note that when using TypeScript you have to wrap the group property in an array? Thanks!
0
Hello Sean,
The intellisense correctly suggests that the accepted object type is "DataSourceGroupItem[]" as seen in the following screenshot from VisualStudio:
Regards,
Vladimir Iliev
Telerik
The intellisense correctly suggests that the accepted object type is "DataSourceGroupItem[]" as seen in the following screenshot from VisualStudio:
Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!