I can not get data from ExtJS store

0

Greetings, I am trying to modify a system that is already done in ExtJS and my problem is when I get data from a store that is as follows:

Ext.define('sistema.store.ProductionPeriodClosureAll', {
extend: 'Ext.data.Store',
model: 'sistema.model.ProductionPeriodClosureModel',
require: [
    'Ext.data.Store', 
    'sistema.model.ProductionPeriodClosureModel'
],

proxy:{
    type: 'ajax',
    api: {
        read: 'rest/productionPeriodClosure/list.htm'
    },
    reader: {
        type: 'json',
        root: 'data',
        idProperty: 'id',
        totalProperty: 'total',
        messageProperty: 'message'
    }
}

});

with that ready the data of a period, now in the Controller of another interface I call that store

var myStore = Ext.create('sistema.store.ProductionPeriodClosureAll').load();

then I try to perform a search:

    var posicion = myStore.findBy(function(record,id){

if (record.get ('closeDate') == '2017-09-01')   return true; else   return false; });

But the result returns me empty, and tried to try with count () to have the value returns but it does not matter.

The objective of these is to compare if a date exists in the store and according to that validate some data.

Thank you in advance.

    
asked by Juan Carlos Silva Panta 14.09.2017 в 01:57
source

1 answer

0

The problem is that you are trying to access the store's records when it is not fully loaded yet, a common problem because the store is Asynchronous . Try sending a callback to the load method to make sure you do the search once it's fully loaded.

Like this:

var myStore = Ext.create('sistema.store.ProductionPeriodClosureAll').load({
    callback: function(){
     //Acciones despues de termina de cargar
    }
});

I hope it's useful for you. Greetings.

    
answered by 29.08.2018 в 19:01