Search code examples
angularkendo-uikendo-ui-angular2angular2-observables

How to use kendo-data-query groupBy with observables


I'm looking for examples of kendo components reading Observables, like this example https://www.telerik.com/kendo-angular-ui/components/dropdowns/multiselect/data-binding/#toc-async-pipe

But the examples that uses kendo-data-query doesn't have Observables

https://www.telerik.com/kendo-angular-ui/components/dropdowns/multiselect/grouping/

Did anyone make one groupBy with Observables?


Solution

  • I found a solution that was on the other side of what I was looking

    public Autocomplete = (): Observable<any> => {
    return this.$http
      .get<any>(this.apiEndpoint + `api/Autocomplete/GetAutocompleteList/`, {
        observe: 'response'
      })
      .pipe(
        map((res: HttpResponse<any>) => {
          return groupBy((<any>res.body.$values).map((item) => {
            return item;
          }), [{ field: "AutoCompleteType" }]);
        }),
        catchError((error: HttpErrorResponse) => {
          return observableThrowError(error);
        })
      );
    

    };