Search code examples
javascriptextjsgridextjs4

Send a grid data to the server Exjts4


As do to send all the data in a grid in extjs to the server?

My Store

var store = Ext.create('Ext.data.Store', {            
            autoDestroy: true,
            autoLoad: true,
            fields: ['property', 'value']
            proxy: {
                type: 'ajax',                
                url: '...',                
                reader: {
                    type: 'json'                                        
                },
                writer: {
                    url: '...',                
                }
            },
            sorters: [{
                property: 'common',
                direction:'ASC'
            }]
        });

I have a grid that uses my store.

I have tried to this but it doesn't work

mygrid.getStore().add(mygrid.getStore().getRange(0,2));

any ideas?


Solution

  • You defined your store as a variable 'store'. So you would just need to call store.save(). The save function will use the url defined by your store.proxy to post the data back to the database.

    I noticed that you are putting a url config inside of your proxy.writer, which doesn't have a url config option. proxy.writer is used to translate the json, xml, etc before it gets to the proxy.

    If you want to use different backend controllers for CRUD operations you could specify these in the api config of the proxy you are using (Ext.data.proxy.Ajax). Take a look at the api config item on this page.