1. #101
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    89
    Vote Rating
    2
    zmagyar is on a distinguished road

      0  

    Default


    BTW the code below doesn't seem to work for me.

    Quote Originally Posted by shepsii View Post
    To remove all records I just use:
    Code:
    store.removeAll();
    store.sync();


  2. #102
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    482
    Vote Rating
    48
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Ok, could you elaborate on "doesn't work" and perhaps post some code?

    I know that code works in one of my apps so there must be a difference in how it's being used.

    Note it's not removed from the database instantly. The db transaction happens in another thread.

    If you want to execute code as soon as it is finished, add a write listener to the store before you sync.

  3. #103
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    89
    Vote Rating
    2
    zmagyar is on a distinguished road

      0  

    Default


    Just figured out that the store needs to be loaded first to get removeAll() working. Is that the expected behavior?

  4. #104
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    482
    Vote Rating
    48
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Yes that would be consistent with how the localstorage proxy works.

    When you do removeAll(), ST2 will get all the records in the store and remove them, and make a record of what was removed so it can be fetched with http://docs.sencha.com/touch/2-0/#!/...RemovedRecords .

    Of course its there's nothing in the store to remove because it hasn't been loaded yet, it won't delete anything!

    Then on a sync call, ST2 sends to the proxy the records to delete which the proxy will then do.

  5. #105
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    89
    Vote Rating
    2
    zmagyar is on a distinguished road

      0  

    Default


    Thanks, it makes sense now.

    Unfortunately I'm hitting another issue now. Probably I'm doing something dumb but multiple records are appearing in the DB now. I'm loading data from an online store to an sqlite store by the code below.
    Code:
                                storeOnlineCustomer.load(function(){
                                    storeOnlineCustomer.each(function (record) {
                                        storeOfflineCustomer.add(record);
                                        console.log('Customer: ', record.data);
                                    });
                                    storeOfflineCustomer.sync();
                                    me.redirectTo('home/');
                                });
    The console log shows the correct number of records. However if I browse the DB 2-3 copies of each record appearing. Is there any clue what could be the reason for that?

  6. #106
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    482
    Vote Rating
    48
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Can you post the model definition?

  7. #107
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    89
    Vote Rating
    2
    zmagyar is on a distinguished road

      0  

    Default


    Code:
    Ext.define('FieldServices.model.Customer', {
        extend: 'Ext.data.Model',
        alias: 'model.Customer',
        uses: [
            'FieldServices.model.Contact',
            'FieldServices.model.Address'
        ],
        config: {
            fields: [
                {
                    name: 'id',
                    type: 'int'
                },
                {
                    name: 'company',
                    type: 'string'
                },
                {
                    name: 'created',
                    type: 'int'
                },
                {
                    name: 'company_id',
                    type: 'int'
                }
            ],
            hasMany: [
                {
                    model: 'FieldServices.model.Contact',
                    autoLoad: true,
                    foreignKey: 'customer_id',
                    name: 'contacts'
                },
                {
                    model: 'FieldServices.model.Address',
                    autoLoad: true,
                    foreignKey: 'customer_id',
                    name: 'address'
                }
            ]
        }
    });

  8. #108
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    482
    Vote Rating
    48
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    Ok, I don't think it's going to work with the hasMany config for starters, but then neither does the localstorage proxy yet!

    My solution for that is just to load stores in for the submodels with remoteFilter: true and then filter by their customer_id field.

    But I can't see from that why multiple records are going into the database. Have you tried dropping the db table and starting again? Maybe it's a bug you've already fixed, but the proxy's not clever enough to try to fix the database on each load.

  9. #109
    Sencha User
    Join Date
    Aug 2011
    Posts
    60
    Vote Rating
    0
    stirucherai is on a distinguished road

      0  

    Default Trying to solve list linked to SQLite Proxy

    Trying to solve list linked to SQLite Proxy


    I have attached a list to SQLite store. The list contionusly shows loading sign. using Java Console I could see that store is loaded but only to 25 elements when actually in DB i have 155.

    Is there some trick I am missing.

    Store Code is as follows

    Code:
    Ext.define('NDP.store.menuList', {
        extend: 'Ext.data.Store',
        requires: 'NDP.model.menuList',
        config : {
            model: 'NDP.model.menuList',
            autoLoad: true,
            root:'root'
        }
    });
    added pagesize = 1000;

    Now it loads all the 154 records. But issue is it is not finishing meaning it is just showing "Loading"

  10. #110
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    482
    Vote Rating
    48
    shepsii has a spectacular aura about shepsii has a spectacular aura about shepsii has a spectacular aura about

      0  

    Default


    If it's loading the records into the store, but they're not showing in the list, that sounds like an issue with the list, not with the proxy. The proxy's job is to get the records into the store - from there touch should take over.

    I'm happy to have a look at the list if you don't mind posting the code for it.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar