Search code examples
extjsextjs3

pass values from editor grid to java in extjs 3.4


I have created an editor grid. enter image description here

After entering values in the grid, I want to pass this values to java and save it into database. I want to pass values after all rows are added into the grid.

I saw an example where the cell had a listener for change event, but I want to get all the rows of the grid. How can I do this?


Solution

  • You need to configure your store with a writer, e.g a JsonDataWriter. When all edits have been made on the grid, you would them call save() on the underlying store and then all record your new records will get sent in a batch to the server.

    This kind of thing

    var writer = new Ext.data.JsonWriter({
        encode: true
    });
    
    // create the Data Store
    
        var store = new Ext.data.JsonStore({
            root: 'data',
            idProperty: 'myid ',
            writer: writer,
            fields: ['myid', 'fieldA', 'fieldB', 'fieldB'],
            proxy: new Ext.data.HttpProxy({
                url: 'YourUrl',
                method: 'POST'
            })
        });