0

I have a project in DevExtreme,mobile.

JavaScript:

var example = new DevExpress.data.DataSource({

    store: example.db.deneme,

    requireTotalCount: true

}).load().done(function (result) {

        alert(result.length);
});
// this

In this code, 'result.length' returns the correct answer.

How to get total count ('result.length') in 'this' place.

Andrea
  • 11,801
  • 17
  • 65
  • 72

1 Answers1

1

The load method of the dataSource works asynchronously. So, you can use the deferred object to implement your scenario:

var deferred = $.Deferred();

example.load().done(function (result, extra) {
    deferred.resolve(extra.totalCount);
});

$.when(deferred).done(function(count){
    alert(count);
});

http://jsfiddle.net/edgc42ga/

Sergey
  • 5,396
  • 3
  • 26
  • 38