Troubleshooting

This article provides solutions for issues you might encounter while working with the Kendo UI TreeList for Angular.

Dates are not properly formatted. During sorting, filtering, or editing, dates are treated as strings.

When the TreeList data contains dates, they need to be instances of the JavaScript Date object. This ensures that dates are handled correctly during formatting, sorting, filtering, and editing.

Solution

If the data is coming serialized from a remote server or for an unspecified reasons the data contains string representations of dates instead of actual JavaScript Date objects, map the data so that each date property has a JavaScript Date as value.

    private fetch(action: string = '', data?: any, id?: any): Observable<Employee[]> {
        let params = new HttpParams();

        if (typeof id !== 'undefined') {
            params = params.set('id', id);
        }

        if (data) {
            params = params.set('models', JSON.stringify([data]));
        }

        return this.http.jsonp<Employee[]>(
            `https://demos.telerik.com/kendo-ui/service/EmployeeDirectory/${action}?${params.toString()}`,
            'callback'
        ).pipe(tap(response =>
            response.forEach(item =>
                item.HiredDate = new Date(item.HiredDate)
            )
        ));
    }