2014-12-11 2 views
0

내가 AngularJS와 UI 그리드의 아 격자로 데이터베이스에서 데이터를 채우기 위해 노력하고 있지만이 작동하지에서 UI 그리드의 하위 그리드에 데이터를 채우는 방법을 코드데이터베이스

입니다 '사용자 : $ resource ('/ rest/daybook/sales_registertest/: id /? app_name = DAYBOOK_NEW & fields = * ', {}, {업데이트 : {방법 :'PUT '}, 검색어 : { 방법 :'GET ', isArray : false }}); {방법 : 'PUT'}, 쿼리 : { 방법

var에 사용자 1 = $ 자원 (: {}, {갱신 '?/휴식/일기/salesdetailtest// APP_NAME = DAYBOOK_NEW & 필드 = * ID' : '얻으십시오', isArray : false }});

User.get(function(data) { 

     for(i = 0; i < data.record.length; i++){ 
      var records; 
     var id=data.record[i].sales_id; 
    User1.get({ 
    sales_id: id 
     }, function(resp) { 
     // Handle successful response here 
     records=resp.record; 
     console.log(records); 
     }, function(err) { 
      // Handle error here 
     }); 
      //alert(id); 
    data.record[i].subGridOptions = { 
     columnDefs: [ 
      {field:'sales_id'}, 
      {field:'product_id'}, 
      {field:'sale_qty'}, 
      {field:'sale_price'}, 
      {field:'sale_amount'}, 
      {field:'product_id'} , 
      {field:'updated_on'} 
     ] 
    }; 
    data.record[i].subGridOptions.data=records; 


    } 

$ scope.gridOptions.data = data.record; } 함수 (ERR) {

})`

내가해야 할 것은이 다른 테이블에서의 주요 계통의 행의 ID에 따라 상기 서브 그리드 도착. 내가 어떻게 이걸 얻을 수 있니?

답변

-1
$http.get('/data/500_complex.json') 
    .success(function(data) { 
     for(i = 0; i < data.length; i++){ 
     //parse the data object and check the database for any relations then grab those as an object and push it into the data[i].subGridOptions 
     data[i].subGridOptions = { 
      columnDefs: [ {name:"Id", field:"id"},{name:"Name", field:"name"} ], 
      data: data[i].friends 
     } 
     } 
     $scope.gridOptions.data = data; 
    });