Get all records from a filter in listview

Hi people.

I am following the following tutorial Tutorial Dashlet listView, to create a Dashlet that allows me to capture the records in the list view depending on the filter. No problem so far. The question is, when they exceed the 20 records that the list view normally shows, I can not process the other records. How can I get all the records that the filter throws? In the tutorial they can process ALL records. I'm use Sugar 9.0, I don't know if that can be changing,

Here is my code

/*************************/

({
// CustomDashletPPPxU View (base)

//This view uses the essential Dashlet plug-in
plugins: ['Dashlet'],

/**
* Values is used by the template to display the statuses and counts. Backs our Handlebars template.
*/
values: undefined,

// prom_values : objeto para almacenar los promedios prom_precioUnidadLiquidado, prom_pesoUnidadLiquidado, prom_precioUnidadFacturado, prom_pesoUnidadFacturado
prom_values : undefined,
/**
* Keeps track of how many cases in total we're displaying. Also used in our Handlebars template.
*/
totalRecords: undefined,

/**
* Keeps a map of status types by model ID as the key.
*/
modelsMap: undefined,

/**
* @inheritdoc
*/
initialize: function(options) {
// call the parent's (View's) initialize function
// passing options as an array
this._super('initialize', [options]);
console.log('1');
// initialize vars
this.modelsMap = {};
this.totalRecords = 0;
this.values = {};
this.prom_values = {};
},

/**
* @inheritdoc
*/
bindDataChange: function() {
console.log('2');
var ctx = this.context,
collection = ctx.get("collection");
if(_.isEmpty(collection)){ //Collection will be empty in "preview" mode
return;
}

//Listening to 'reset' events on the collection
collection.on('reset', function(collection) {
// Ensure that collection exists, has models, then parse out models for display
if(collection && collection.length) {
this._parseModels(collection.models, false);
}
}, this);

//Listening to 'add' and 'remove' events on the collection
collection.on('add remove', function(model, collection, options) {
// The Backbone's options argument for 'add' and 'remove' events are different
// if options.removed doesn't exist, then we will know this is a 'remove' event
if (_.isUndefined(options.remove)) {
options.remove = true;
}

// Backbone passes add/remove options as an event param, so we can tell
// if this was the add or remove event and pass it to parseModels
this._parseModels([model], options.remove);
}, this);

if(collection.models && _.isEmpty(this.modelsMap)) {
// manually cause a parsing of the models
// this covers the scenario when a user creates a new record
this._parseModels(collection.models, true);
}
},

/**
* Recalculates values used in the template from modelsMap
*
* @private
*/
_recalcValues: function() {
var recordSize = Object.keys(this.modelsMap).length;
//sum_values : objeto utilizado para almacenar las sumas unidadesLiquidadas, fleteLiquidado, pesoLiquidado, fleteFacturado, pesoLiquidado
//sum_values : undefined,

// prom_values : objeto para almacenar los promedios prom_precioUnidadLiquidado, prom_pesoUnidadLiquidado, prom_precioUnidadFacturado, prom_pesoUnidadFacturado
//prom_values : undefined,
console.log('3');
// reset values
this.values = {};
this.totalRecords = 0;
//Sumas totales

unidadesLiquidadas = 0;
fleteLiquidado = 0;
pesoLiquidado = 0;
fleteFacturado = 0;
unidadesFacturadas = 0;

_.each(_.values(this.modelsMap), function(data) {
this.totalRecords++;
if(data != undefined && data != null){
//El objeto con las sumatorias existe y se puede procesar
unidadesLiquidadas += (data.unidadesLiquidadas != undefined && data.unidadesLiquidadas != null && !isNaN(data.unidadesLiquidadas)) ? data.unidadesLiquidadas : 0;
fleteLiquidado += (data.fleteLiquidado != undefined && data.fleteLiquidado != null && !isNaN(data.fleteLiquidado)) ? data.fleteLiquidado : 0;
pesoLiquidado += (data.pesoLiquidado != undefined && data.pesoLiquidado != null && !isNaN(data.pesoLiquidado)) ? data.pesoLiquidado : 0;
fleteFacturado += (data.fleteFacturado != undefined && data.fleteFacturado != null && !isNaN(data.fleteFacturado)) ? data.fleteFacturado : 0;
unidadesFacturadas += (data.unidadesFacturadas != undefined && data.unidadesFacturadas != null && !isNaN(data.unidadesFacturadas)) ? data.unidadesFacturadas : 0;
}

if(recordSize === this.totalRecords ){
this.prom_values['prom_precioUnidadLiquidado'] = {
name : 'LBL_PROM_PRECIO_UNIDAD_LIQUIDADO',
prom : (fleteLiquidado / unidadesLiquidadas).toFixed(2)
};

this.prom_values['prom_pesoUnidadLiquidado'] = {
name : 'LBL_PROM_PESO_UNIDAD_LIQUIDADO',
prom : (pesoLiquidado / unidadesLiquidadas).toFixed(2)
};
this.prom_values['prom_precioUnidadFacturado'] = {
name : 'LBL_PROM_PRECIO_UNIDAD_FACTURADO',
prom : (fleteFacturado / unidadesFacturadas).toFixed(2)
}
this.prom_values['prom_pesoUnidadFacturado'] = {
name : 'LBL_PROM_PESO_UNIDAD_FACTURADO',
prom : (pesoLiquidado / unidadesFacturadas).toFixed(2)
}
console.log('Valores promedios', this.prom_values);
}
}, this);

},

/**
* Takes an array of models and parses them into modelsMap then (re)counts the values in this map
*
* @param {Array} models The Array of models to parse
* @param {Boolean} remove If the models passed in should be removed or not
* @private
*/
_parseModels: function(models, remove) {
console.log('4');
var id,
fleteLiquidado,
pesoLiquidado,
fleteFacturado,
unidadesLiquidadas,
unidadesFacturadas,
status;

_.each(models, function(model) {
// get the case id & status
id = model.get('id');
status = "prueba";
fleteLiquidado = model.get('sasa_fleteliquidado_c');
pesoLiquidado = model.get('sasa_pesoliquidado_c');
fleteFacturado = model.get('sasa_fletefacturado_c');
unidadesLiquidadas = model.get('sasa_unidadesliquidadas_c');
unidadesFacturadas = model.get('sasa_unidadesfacturadas_c');
//status = model.get('status');

if (remove && this.modelsMap[id]) {
// if the function was called
// to remove models, delete the id/value
delete this.modelsMap[id];
} else {
// otherwise, add the id and status
// to modelsMap
this.modelsMap[id] = {
'fleteLiquidado' : fleteLiquidado,
'pesoLiquidado' : pesoLiquidado,
'fleteFacturado' : fleteFacturado,
'unidadesLiquidadas' : unidadesLiquidadas,
'unidadesFacturadas' : unidadesFacturadas
};
}
}, this);

// now that we've updated the modelsMap,
// recalculate the this.values object for rendering
this._recalcValues();

// double-check that the view has not been disposed
// if not, then re-render the dashlet
if (!this.disposed) {
this.render();
}
}
})

/*************************/