1. #1
    Sencha Premium Member
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    330
    Vote Rating
    1
    PranKe01 is on a distinguished road

      0  

    Question Does clearOnPageLoad not work with default data?

    Does clearOnPageLoad not work with default data?


    Hi guys,

    I got a list which gets its data from a jsonp proxy. For example I get 3 items. Item1, Item2 and Item3.
    What I want is that by default a fourth item exists which is named "Please select". Because I don't want to change the webservice, I thought, that I put the 4th item into the data-property and set ClearOnPageLoad to false. But that does not work. The item gets removed when the data comes in... Here is my config:

    Code:
    Ext.define('IP.store.base.TestStore', {    extend: 'Ext.data.Store',
        requires: [
            'IP.model.TestModel'
        ],
    
    
        config: {
            autoLoad: true,
            clearOnPageLoad: false,
            data: [
                {
                    id: 0,
                    name: 'Please select'
                }
            ],
            model: 'IP.model.TestModel',
            storeId: 'TestStore',
            proxy: {
                type: 'jsonp',
                url: 'http://localhost/GetData',
                reader: {
                    type: 'json',
                    idProperty: 'id',
                    root: 'data'
                }
            }
        }
    });
    The ids of item1-3 got the values 1, 2 and 3.

    Any hints, why the default-item get removed?
    Thanks

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2009
    Location
    Germany
    Posts
    330
    Vote Rating
    1
    PranKe01 is on a distinguished road

      0  

    Default


    Ah. From the docs: "True to empty the store when loading another page via loadPage, nextPage or previousPage (defaults to true)." So my new question is: how do I load data from the proxy without deleting the existing data?

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    350
    Vote Rating
    1
    bharatn is on a distinguished road

      0  

    Default


    I dont think your case can work out of the box. You could try this
    1. Set autoLoad = false
    2. You will need to add custom code in your store impl class to load data via store.add which appends the data

Thread Participants: 1