1. #1
    Ext JS Premium Member
    Join Date
    Oct 2010
    Location
    Freiburg
    Posts
    18
    Vote Rating
    1
    chrisjs is on a distinguished road

      0  

    Question Data in Reader but not in Store

    Data in Reader but not in Store


    Hello,

    i have a problem with my current work, a user manager.
    User list shows up, i select a row in the grid and a hit on button (or double clicking the row) shows a detail window for editing. I load the user data into a form and i load dependent data (i.e. the applications the user has activated) to show in a second tab.

    The ajax request is working, the server returns correct json data with the dependent data, but the store for the dependent data is empty. When i examine the store in firebug, i see the received data in proxy > reader > rawData.

    this is the user model
    Code:
    Ext.define('AccountManager.model.User', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'account_id'},
            {name: 'ikz'},
            {name: 'account'},
            {name: 'email'},
            {name: 'anrede'},
            {name: 'vorname'},
            {name: 'nachname'},
            {name: 'ka_vorwahl'},
            {name: 'ka_telefon'},
            {name: 'ka_fax'},
            {name: 'gesperrt'},
            {name: 'angelegt_von'},
            {name: 'angelegt_am', type: 'date', dateFormat: 'Y-m-d'},
            {name: 'update_passwd', type: 'date', dateFormat: 'Y-m-d'},
    //        {name: 'notice_passwd', type: 'date', dateFormat: 'Y-m-d'},
            {name: 'bearbeitet_von'},
            {name: 'bearbeitet_am', type: 'date', dateFormat: 'Y-m-d'},
            {name: 'verfahren', type: 'Application'}
        ],
        idProperty: 'account_id',
        proxy: {
            type: 'ajax',
            api: {
                read: '/admin/userread',
                update: '/admin/userupdate'
            },
            reader: {
                type: 'json',
                root: 'results',
                successProperty: 'success',
                totalProperty: 'total'
            },
            writer: {
                type: 'json',
                root: 'user'
            },
            simpleSortMode: true
        }
    });
    this is the application model
    Code:
    Ext.define('AccountManager.model.Application', {
        extend: 'Ext.data.Model',
        fields: [
            'account_id',
            'verfahrens_key', 'email_benachrichtigung', 
            {name: 'bezeichnung', mapping: 'anwendung_text'}
        ],
        idProperty: ['account_id', 'verfahrens_key'],
    
        proxy: {
            type: 'ajax',
            url: '/admin/accountverfahren',
            reader: {
                type: 'json',
                root: 'results',
                successProperty: 'success',
                totalProperty: 'total'
            },
            simpleSortMode: true
        }
    });
    this is the application store
    Code:
    Ext.define('AccountManager.store.Applications', {
        extend: 'Ext.data.Store',
        model: 'AccountManager.model.Application',
    
        remoteSort: false
    });
    The next problem is to set this store as data store for an ItemSelector widget, but first i need to get the data in the store.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    So you load the user data and that works. Then you load the applications store?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Ext JS Premium Member
    Join Date
    Oct 2010
    Location
    Freiburg
    Posts
    18
    Vote Rating
    1
    chrisjs is on a distinguished road

      0  

    Default


    Yes, i load the applications store and in the callback of the load function, i log the store to the console. The data property of the store is empty.

  4. #4
    Ext JS Premium Member
    Join Date
    Oct 2010
    Location
    Freiburg
    Posts
    18
    Vote Rating
    1
    chrisjs is on a distinguished road

      0  

    Default


    Hello,

    i found the solution by myself:

    i use a filter and load the store

    Code:
    edit: function() {
        var appStore = this.getApplicationsStore();
        
        appStore.clearFilter(true);
        // this does not work
        appStore.filter('accountId', accountId);
        
        appStore.load();
    }
    the problem is that there is no field with the name accountId in the model, the filter name has to be 'account_id'. So when i changed the filter name, it works!

    Code:
        
        // setting the filter like this, data will be parsed correctly
        appStore.filter('account_id', accountId);

Tags for this Thread