2016-09-09 41 views
0

目前我正在從服務器檢索數據。UI-GRID顯示json數據

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

[{},{}]所以這就是我的json對象的外觀。

當我調用$ http服務,並把它放在gridOptions:{數據:this.data} 我得到這個錯誤在控制檯窗口:類型錯誤:newRawData.forEach不是一個函數

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() 
    }; 

這是我目前使用的代碼。

任何想法如何擺脫這個錯誤?有可能網格只顯示localCompany.Id而不是名稱:demo?

回答

0

嘗試把數據$ scope.data

像$ scope.data =的GetData從服務器

然後

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

0

data分成$scope而不是gridOptions.data = $scope.data

如果你想顯示localCompany.id您需要定義columnDefs現場request與像自定義模板唯一的數據:

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