1. #1
    Sencha User
    Join Date
    Jul 2011
    Location
    Nantes
    Posts
    9
    Vote Rating
    0
    gfevrier is on a distinguished road

      0  

    Default Getting store saved records on server

    Getting store saved records on server


    Hello,

    I created a grid panel with a store.
    Data are from a PHP script.
    It is possible to modify data in the grid (rowEditing) and to update the store.

    When the user click on a button in the grid toolbar, data are sent to a PHP script on the server. I can see it in Firebug.

    The question is : how can I get the data transmitted in PHP ? I can't see them in the POST or the GET variables... I think it's very simple, but I can't do it.

    firebug_nov.png

    Gilles

  2. #2
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      0  

    Default


    Hi gfevrier,

    How are you using the submit?
    I am sorry my english, I am learning yet
    Portuguese blog: http://wessdevel.blogspot.com.br/
    Twitter: @wlegolas

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Location
    Nantes
    Posts
    9
    Vote Rating
    0
    gfevrier is on a distinguished road

      0  

    Default


    Hi,

    This is the code :

    Code:
    var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
            clicksToMoveEditor  : 2,
            autoCancel          : false
        });
    
        if (Ext.grid.RowEditor) {
            Ext.grid.RowEditor.prototype.saveBtnText = "Mettre à jour";
            Ext.grid.RowEditor.prototype.cancelBtnText = "Annuler";
        }
    
        Ext.define('Enfants', {
            extend: 'Ext.data.Model',
            fields: [
                { name : 'id_enfant'        , mapping : 'id_enfant'     },
                { name : 'nom'              , mapping : 'nom'           },
                { name : 'prenom'           , mapping : 'prenom'        },
                { name : 'ville'            , mapping : 'ville'         },
                { name : 'commentaire'      , mapping : 'commentaire'   },
                { name : 'distribution'     , mapping : 'distribution'  }
            ],
            idProperty: 'id_enfant'
        });
    
        listeEnfantsStore = Ext.create('Ext.data.Store', {
            id          : 'listeEnfantsStore',
            model       : Enfants,
            proxy       : {
                type    : 'ajax',
                method  : 'POST',
                reader  : {
                    type    : 'json'
                },
                writer  : {
                    type    : 'json'
                },
                api     : {
                    read    :  'ajax/liste_enfants.php',
                    update  : 'ajax/enregistre_enfants.php'
                }
            },
            autoLoad    : true
        });
    And in the grid definition :

    Code:
    plugins     : [rowEditing],
    tbar        : [{
                text    : 'Enregistrer les données',
                handler : function() {
                    listeEnfantsStore.sync();
                }
    }]
    Data are thrown to server when I call the "sync" method on the "listeEnfantStore" store.

    Thanks for your help.

    Gilles

  4. #4
    Sencha User Legolas's Avatar
    Join Date
    Apr 2010
    Location
    Brazil/MG
    Posts
    58
    Vote Rating
    3
    Legolas is on a distinguished road

      0  

    Default


    gfevrier, you need to inform in your Writer the parameter name for submit this record:
    Code:
    listeEnfantsStore = Ext.create('Ext.data.Store', {
        id          : 'listeEnfantsStore',
        model       : Enfants,
        proxy       : {
            type    : 'ajax',
            method  : 'POST',
            reader  : {
                type    : 'json'
            },
            writer  : {
                type    : 'json',
                // Added a new properties
                encode: true,
                nameProperty: 'mapping',
                root: 'data' // Important
            },
            api     : {
                read    :  'ajax/liste_enfants.php',
                update  : 'ajax/enregistre_enfants.php'
            }
        },
        autoLoad    : true
    });
    See in API Doc the class "Ext.data.writer.Json" for more informations.
    In your PHP you can get this object by parameter $_POST["data"].
    I am sorry my english, I am learning yet
    Portuguese blog: http://wessdevel.blogspot.com.br/
    Twitter: @wlegolas

  5. #5
    Sencha User
    Join Date
    Jul 2011
    Location
    Nantes
    Posts
    9
    Vote Rating
    0
    gfevrier is on a distinguished road

      0  

    Default


    Yeeeeessssssss !!! Thank you very very much ! I read the documentation but I haven't understood it in the right way...

    It works well know !

    Gilles

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar