Threaded View

  1. #1
    Sencha User
    Join Date
    Mar 2009
    Vote Rating
    Speedy is on a distinguished road


    Default Answered: How to insert a new record to a store

    Answered: How to insert a new record to a store

    Hi there,

    i defined a store

    Ext.define( '' , {
        extend: '',
        autoLoad: true, fields: ['display', 'value'], name: 'myStore', storeId: 'myStore',
        proxy: {
            type: 'ajax', url:'myUrl',
            extraParams: { ... },
            reader: {
                type: 'json', root: 'data', idProperty: 'value'
    in my Application I create this store via

    var store = Ext.create( '', {} );
    so far everything works fine, the store is loaded and used within a combobox.
    now I want to add a new record to the store and I tried
    store.add({ display: 'abc', value: '0' });

    store.insert( 0, { display: 'abc', value: '0' });

    since the data of the loaded store start their values from 1-15 I thought 0 or 16 should work but there simple happens nothing. No error, no new entry.

    What am I doing wrong?



  2. If you specify fields instead of a model then the store will create an implicit model. This shouldn't be a problem.

    When you call add() or insert() it is expecting to be passed records. However, from a quick look at the code, it is clear that if you don't pass it records it will create a record for you from the model (in your case, the implicit model).

    I tried your code for myself and as far as I could tell it works fine: add() and insert() both do exactly what you'd expect.


    If the data is loaded via Ajax then you have to wait until after the data is loaded before adding the new record. When the Ajax request completes it will blow away any existing records before adding its new records.

    I also briefly had a problem using the store with a combobox. I forgot to include queryMode: 'local', which resulted in a second Ajax request being made that blew away my new record. This is easily diagnosed, just watch the network activity in Firebug or the Chrome Developer Tools to check it isn't performing an extra request.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."