添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I am trying to replicate the sample at https://www.telerik.com/kendo-angular-ui/components/grid/data-operations/data-binding/.I am getting the following error highlighted on my VS2017 and during run time:

Argument of type 'null' is not assignable to parameter of type 'GridDataResult'.

the error is occurring because of this code:

export abstract class NorthwindService extends BehaviorSubject<GridDataResult> {
constructor(
private http: HttpClient,
protected tableName: string
super( null );//this line is causing 'Argument of type 'null' is not assignable to parameter of type 'GridDataResult'

Thanks

Madani

Hi Madani,
This is a TypeScript error that can be easily fixed by passing an object of type GridDataResult (one containing data and total properties) to satisfy the type checking, e.g.:
const emptyDataResult = {
data: [],
total: 0
super( emptyDataResult );
http://plnkr.co/edit/Ng27Jc7Hf0rHHADv17Qu?p=preview
Alternatively you can use type casting to cast the argument to the expected GridDataResult type.
I hope this helps.
Regards,
Dimiter Topalov
Progress Telerik Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.

http://plnkr.co/edit/Ng27Jc7Hf0rHHADv17Qu?p=preview

protected fetch(tableName: string, state: any): Observable<GridDataResult> {
const queryStr = `${toODataString(state)}&$count=true`;
return this.http
.get(`${this.BASE_URL}${tableName}?${queryStr}`)
.map(response => (<GridDataResult>{
data: response['value'],
total: parseInt(response["@odata.count"], 10)

getting error at

data: response['value'],
total: parseInt(response["@odata.count"], 10)

Error TS7017 (TS) Element implicitly has an 'any' type because type 'Response' has no index signature.

Hi Ruchika,
This is a typical TypeScript error, thrown when indexing property access syntax is attempted on an object that does not have an index signature:
https://stackoverflow.com/questions/32968332/how-do-i-prevent-the-error-index-signature-of-object-type-implicitly-has-an-an
In the discussed example, this type of accessing the response's fields is imposed by the specifics of the OData protocol. You can resolve it either by disabling the " noImplicitAny " TypeScript flag, or providing the verbose signature as described in the StackOverflow thread, linked above.
I hope this helps.
Regards,
Dimiter Topalov
Progress Telerik Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.