简体   繁体   中英

Sencha Touch Store Add replaces record 1

I extended an Ext.data.Store (ie users with model user) but when I iterate over custom JSON response and add each record, it replaces the first record and so the store consist of just one record instead of many

Here is my code (in image format) notice in line 215 i added a model on store on each iteration: 在此处输入图片说明

And here is the console output w/c only shows 1 on getCount(): 在此处输入图片说明

I tried many solutions, and that includes changing the 'id' attribute to something else and also differ my user model to users model

But I have another store that is adding fine without problems.

EDIT: I tried adding it through javascript console and still it replaces the record 1: 在此处输入图片说明

The store's add function will automatically handle creation of the model(s). Your callback should be as simple as this:

callback: function(optionsusers, successusers, responseusers) {
    loadingLoginModal.hide();

    var responseusersJSON = Ext.JSON.decode(responseusers.responseText);
    userStore.add(responseusersJSON);

    loadingLoginModal.destroy();
    that.showHomeView();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM