2016-04-12 24 views
0

Kendo grid dataSource uzunluğunu bulmaya çalışıyorum, ancak her zaman karşılığında 0 alıyorum. DataSource'un toplam uzunluğunu nasıl alabilirim? Izgara için dataSource olan Control servisini ekledim.Kendo dataSource uzunluğunu nasıl bulabilirim?

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

dataBound etkinlik için bir işlev oluşturun ... ızgara için HTML varsayarsak

$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'unuz ('GRID DATA', data);' return? – Akis

+0

0 her zaman – hussain

+0

döndürür sonra benim veri kaynağım – Akis

cevap

0

gibi görünür ctrl.js ...

function onDataBound(e) { 
    console.log(e.sender.dataSource.view().length); 
}