Results 1 to 4 of 4

Thread: Grid data into spring controller

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    46
    Answers
    5
    Vote Rating
    3
      0  

    Default Answered: Grid data into spring controller

    Hi ,

    I have problem with extjs grid , I want to send grid data record as a json object ,


    my grid all fields all editable , and it's have many records , I want to save in database table ,

    could you give easy solution for ths problem,

    Thanks & Regards,
    Yakambram Sai

  2. It's not clear what you actually want to know.

    If you're asking about sending the JSON data to the server, look at the store's sync() method.

    If you're asking how to handle saving the JSON data on the server side, that really has nothing to do with Ext JS. Use whatever mechanism your chosen platform provides to parse incoming JSON data and persist it. How that is done depends entirely on your server-side setup.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,409
    Answers
    716
    Vote Rating
    504
      0  

    Default

    This is handled by your proxy. Here is a quick setup that show how the data is sent in the header you modify a field
    Check the header on your Network/xhr tab in your debugger and then inspect the header for update.php error call

    This just shows the client side, you would need to address the incoming data on your server side.

    Code:
    {
        'items': [
            {
                'name'   : 'Lisa',
                'email'  : 'lisa@simpsons.com',
                'change' : 80
            },
            {
                'name'   : 'Bart',
                'email'  : 'bart@simpsons.com',
                'change' : 20
            },
            {
                'name'   : 'Homer',
                'email'  : 'home@simpsons.com',
                'change' : 23
            },
            {
                'name'   : 'Marge',
                'email'  : 'marge@simpsons.com',
                'change' : -11
            }
        ]
    }
    Code:
    Ext.define('MyModel', {
        extend : 'Ext.data.Model',
    
        fields  : [
            { name: 'name' },
            { name: 'email' },
            { name: 'change' }
        ]
    });
    
    Ext.onReady(function(){
     
        var store = Ext.create('Ext.data.Store', {
            autoLoad  : true,
            
            autoSync  : true,
            
            model     : 'MyModel',
            proxy     : {
                type   : 'ajax',
                
                //url    : 'data.json',
                
                api : {
                    read    : 'data.json',
                    create  : 'create.php',
                    update  : 'update.php',
                    destroy : 'destroy.php'
                },            
                
                reader : {
                    type   : 'json',
                    root   : 'items'
                }
            }
        });
    
    
        var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit : 1
        });
    
        Ext.create('Ext.grid.Panel', {
            title    : 'Simpsons',
            store    : store,
            selModel : {
                selType: 'cellmodel'
            },
            columns  : [
                { header : 'Name', dataIndex : 'name', editor : { xtype : 'textfield' } },
                { header : 'Email', dataIndex : 'email', flex : 1, editor : { xtype : 'textfield' } },
                { header : 'Change', dataIndex : 'change', editor : { xtype : 'textfield' } }
            ],
            height   : 200,
            width    : 400,
            renderTo : Ext.getBody(),
    
            plugins : [ cellEditing ]
    
        });
    
    });

  4. #3
    Sencha Premium Member
    Join Date
    Oct 2013
    Posts
    46
    Answers
    5
    Vote Rating
    3
      0  

    Default grid data

    my problem is different , my screen window have many grids those all are editable and I have separate button to save , when I click on that button those grid values should be save in data base table record wise

  5. #4
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Raleigh, NC
    Posts
    501
    Answers
    23
    Vote Rating
    464
      0  

    Default

    It's not clear what you actually want to know.

    If you're asking about sending the JSON data to the server, look at the store's sync() method.

    If you're asking how to handle saving the JSON data on the server side, that really has nothing to do with Ext JS. Use whatever mechanism your chosen platform provides to parse incoming JSON data and persist it. How that is done depends entirely on your server-side setup.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •