0

我正在尝试将数据库中的数据填充到 angularjs ui-grid 的子网格中,但它不起作用这是代码

`var User = $resource('/rest/daybook/sales_registertest/:id/?app_name=DAYBOOK_NEW&fields=*', {}, { update: { method: 'PUT' }, query: { method: 'GET', isArray : 错误的 } });

var User1 = $resource('/rest/daybook/salesdetailtest/:id/?app_name=DAYBOOK_NEW&fields=*', {}, { update: { method: 'PUT' }, query: { method: 'GET', isArray:错误的 } });

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; },函数(错误){

});`

我需要做的是,根据主网格中行的id从不同的表中获取子网格。我怎样才能做到这一点?

4

1 回答 1

-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;
    });
于 2015-01-09T07:30:42.480 回答