0

At the moment I am retrieving data from the server.

[
  {
    id:1, 
    name:demo,
    request: {
      id: 1,
      localCompany: {
        id: 1
      }
   }
}]

[{ }, { }] so this is how my json object looks.

When I get call the $http service and put it in the gridOptions: {data: this.data} I get this error in the console window: TypeError: newRawData.forEach is not a function.

 data: ng.IPromise<any[]> = this.programService.getRequestsForProgram(this.model.id).then((data: any) => {
        console.log(data);
        return data;
    });

gridOptions: {} = {
        data: this.data ,
        paginationPageSize: 5
        //columnDefs: this.programCountryService.getHeaders()
    };

This is the code I am using at the moment.

Any idea how I can get rid of this error? And is it possible that the grid only shows localCompany.Id and not the name:demo?

Brent Theunckens
  • 105
  • 1
  • 13

2 Answers2

0

Try to put the data in $scope.data

Like $scope.data=getdata from server

and then

gridOptions: {} = { data: $scope.data , paginationPageSize: 5 //columnDefs: this.programCountryService.getHeaders() };

Munna S
  • 17
  • 6
0

Put data into $scope and than to gridOptions.data = $scope.data.

If you want to show only data for localCompany.id you need to make definition for columnDefs for field request with custom template like:

'<div class="ui-grid-cell-contents">{{ COL_FIELD.id }}</div>'