correct grid sample https://plnkr.co/edit/h1EB4cKEZpm4q3jHX8ye?p=preview&preview

1 Answer 98 Views
Grid
bahaso
Top achievements
Rank 1
Iron
Iron
Iron
bahaso asked on 05 Jul 2021, 07:51 AM | edited on 05 Jul 2021, 08:48 AM

Hi,

Could you upgrade sample https://plnkr.co/edit/h1EB4cKEZpm4q3jHX8ye?p=preview&preview for Angular12

I have problem with asc and curr which has no type and "filter" is not defined

 

Regards

 

const flatten = filter => {
const filters = filter.filters;
if (filters) {
return filters.reduce((acc, curr) => acc.concat(curr.filters ? flatten(curr) : [curr]), []);
}
return [];
};

 

class NorthinService method fetch has also problem in Angular12

protected fetch(tableName: string, state: any): Observable<GridDataResult> {
const queryStr = `${toODataString(state)}&$count=true`;

return this.http
.get(`${this.BASE_URL}${tableName}?${queryStr}`)
.pipe(
map(response => (<GridDataResult>{
data: response['value'],
total: parseInt(response['@odata.count'], 10)
}))
);
}

1 Answer, 1 is accepted

Sort by
0
Yanmario
Telerik team
answered on 08 Jul 2021, 06:59 AM

Hi Bahaso,

Thank you for the provide code snippets.

Indeed some of our demos aren't compatible with TypeScript strictTemplatesthus types need to be assigned. This would be fixed in the feature and in the meantime, the following code snippets would fix the errors:

const flatten = (filter: CompositeFilterDescriptor): Array<FilterDescriptor> => {
    const filters = filter.filters;
    if (filters) {
        return filters.reduce((acc: Array<any>, curr: any) => acc.concat(curr.filters ? flatten(curr) : [curr]), []);
    }
    return [];
};

As for the service, the response should be assigned to its respective type. However for the purpose of the demo, we left it with an any type, but the developer can further extend the implemented code, by adding its own interfaces which conform with the project requirements:

  return this.http.get(`${this.BASE_URL}${tableName}?${queryStr}`).pipe(
            map(
              (response: any) =>
                <GridDataResult>{
                  data: response["value"],
                  total: parseInt(response["@odata.count"], 10),
                }
            ),
          );

I hope this helps.

Regards,
Yanmario Menev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
bahaso
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Yanmario
Telerik team
Share this question
or