2016-04-12 1 views
0

私は剣道グリッドのデータソースの長さを見つけようとしていますが、私は常に0になっています。 dataSourceの全長を取得するにはどうすればよいですか?グリッド用のdataSourceであるControlサービスを追加しました。剣道データソースの長さはどのようにして確認できますか?

ctrl.js

$scope.alignedProcessesToControlGridOptions.dataSource = ControlRatingGridDataService.getAlignedProcessesToControlGrid($stateParams.controlId); 
    var data = $scope.alignedProcessesToControlGridOptions.dataSource.data().length; 
    console.log('GRID DATA', data); 

DataService.js

getAlignedProcessesToControlGrid: function(controlKey) { 
    var countNew = 0; 
    return new kendo.data.DataSource({ 
     type: 'json', 
     serverPaging: true, 
     serverSorting: true, 
     serverFiltering: true, 
     transport: { 
      read: function(options) { 
       var gridSearchObject = { 
        skip: options.data.skip, 
        take: options.data.take, 
        pageSize: options.data.pageSize, 
        page: options.data.page, 
        sorting: options.data.sort, 
        filter: options.data.filter 
       }; 
       return $http.post(
        'app/control/rest/allAlignedProcessesToControl/' + controlKey, gridSearchObject).success(
        function(data) { 
         countNew = data.totalCount; 
         options.success(data.resultDTOList); 
        }); 
      } 

     }, 
     pageSize: 5, 
     schema: { 
      model: { 
       id: 'riskInProcessKey', 
       fields: { 
        processName: { 
         editable: false 
        }, 
        epcfName: { 
         editable: false 
        }, 
        erhName: { 
         editable: false 
        }, 
        ctlGeolocationsText: { 
         editable: false 
        }, 
        ctlPerformanceRatingText: { 
         editable: false 
        }, 
        ctlEffectivenessRatingText: { 
         editable: false 
        } 
       } 
      }, 
      total: function() { 
       return countNew; 
      } 
     } 
    }); 
}, 
+0

あなたの 'console.log( 'GRID DATA'、data);' return? – Akis

+0

常に0を返します – hussain

+0

データソースにデータがありません – Akis

答えて

0

は、グリッドのためのあなたのHTMLを想定するとは何かのように見える...

$("#grid").kendoGrid({ 
      dataSource: { 
       // your datasource 
      }, 
      dataBound: onDataBound 
    }); 

dataBoundイベントのための関数を作成します...

function onDataBound(e) { 
    console.log(e.sender.dataSource.view().length); 
} 
関連する問題