Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does store.loadData fires load event on the store on ExtJs 4.2.5?

Does store.loadData fires load event on the store on ExtJs 4.2.5 ?

The documentation states it does: http://docs-devel.sencha.com/extjs/4.2.5/#!/api/Ext.data.Store-method-loadData

But given what I've experienced it doesn't look like it does and also looking at the source code:

loadData: function(data, append) {
    var length = data.length,
        newData = [],
        i;

    //make sure each data element is an Ext.data.Model instance
    for (i = 0; i < length; i++) {
        newData.push(this.createModel(data[i]));
    }

    this.loadRecords(newData, append ? this.addRecordsOptions : undefined);
},

ok so probably loadRecords is firing it right?

loadRecords: function(records, options) {
    var me     = this,
        i      = 0,
        length = records.length,
        start,
        addRecords,
        snapshot = me.snapshot;

    if (options) {
        start = options.start;
        addRecords = options.addRecords;
    }

    if (!addRecords) {
        delete me.snapshot;
        me.clearData(true);
    } else if (snapshot) {
        snapshot.addAll(records);
    }

    me.data.addAll(records);

    if (start !== undefined) {
        for (; i < length; i++) {
            records[i].index = start + i;
            records[i].join(me);
        }
    } else {
        for (; i < length; i++) {
            records[i].join(me);
        }
    }

    /*
     * this rather inelegant suspension and resumption of events is required because both the filter and sort functions
     * fire an additional datachanged event, which is not wanted. Ideally we would do this a different way. The first
     * datachanged event is fired by the call to this.add, above.
     */
    me.suspendEvents();

    if (me.filterOnLoad && !me.remoteFilter) {
        me.filter();
    }

    if (me.sortOnLoad && !me.remoteSort) {
        me.sort();
    }

    me.resumeEvents();
    if (me.isGrouped()) {
        me.constructGroups();
    }
    me.fireEvent('datachanged', me);
    me.fireEvent('refresh', me);
},

It's not fired there either.

Is this a known issue or am I missing something ?

like image 703
code4jhon Avatar asked Sep 25 '22 03:09

code4jhon


1 Answers

loadData does not fire the load event, because the load event fires whenever the store reads data from a remote data source (docs). loadData works with local data provided in its first argument.

You've found an inaccuracy in the documentation. I followed your research in version 4.1.1 and I couldn't find loadData firing the load event there.

However loadRawData used to fire the load event in 4.1.1, but it doesn't anymore in 4.2.5. In the source code you can read:

As of 4.2, this (loadRawData) method will no longer fire the {@link #event-load} event.

like image 168
Christiaan Westerbeek Avatar answered Sep 28 '22 06:09

Christiaan Westerbeek