1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    11
    Vote Rating
    0
    OtavioF is on a distinguished road

      0  

    Default Answered: Problem with rowEditing Plugin.

    Answered: Problem with rowEditing Plugin.


    I'm having a problem to get the values typed in the rowEditing plugin. When I type the values, I can't get it back with function.

    error message: Uncaught TypeError: Cannot call method 'get' of undefined.

    I hope you can help me, here's the script code:

    Code:
    Ext.define('Person', {            extend: 'Ext.data.Model',
                idProperty: 'dadosdobanco',
                fields: [
                   {name: 'idproduto_pontuacao'},
                   {name: 'ano'},
                   {name: 'valor'},
                   {name: 'menor'},
                   {name: 'maior'}
                ]        
            });    
    
    
            var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
                listeners: {
                    clicksToEdit: 2,
                    edit: function(e){
                        
                        Ext.Ajax.request({
                            url: "../comercial/produtos",
                            method:'POST',
                            params: {
                                acao: 'salvapontuacao',
                                ano: e.record.get('ano'),
                                valor: e.record.get('valor'),
                                menor: e.record.get('menor'),
                                maior: e.record.get('maior')
                                
                            },
                            beforeSend: function(){
                            },
                            success: function(e){
                                if(acao == 'inserir'){
                                       store_pontuacao.load();    
                                }                                  
    
    
                            }
                        })
                    }
                }
                    
            });
    
    
            var store_pontuacao = Ext.create('Ext.data.Store', {
                autoLoad: true,
                //autoSync: true,
                model: 'Person',
                proxy: {
                    type: 'rest',
                    url: '../comercial/produtos',
                    reader: {
                        type: 'json',
                        root: 'data'
                    },
                    writer: {
                        type: 'json'
                    },
                    actionMethods: {
                        create : 'POST',
                        read   : 'POST',
                        update : 'POST',
                        destroy: 'POST'
                    },
                    extraParams:{
                        acao: 'pontuacao'
                    }
                }
            });
            
            //Cria a grid da aba de pontuação
            
            var grid2 = Ext.create('Ext.grid.Panel', {
                width: 740,
                height: 275,
                plugins: [rowEditing],
                store: store_pontuacao,
                columns: [{
                    text: 'Ano',
                    sortable: true,
                    dataIndex: 'ano',
                    width: 179,
                    field: {
                        xtype: 'textfield'
                        }
                    }, {
                    text: 'Valor',
                    sortable: true,
                    dataIndex: 'valor',
                    width: 180,
                    field: {
                         xtype: 'textfield'
                        }
                    }, {
                    text: 'Menor',
                    sortable: true,
                    dataIndex: 'menor',
                    width: 188,
                    field: {
                    xtype: 'textfield'
                        }
                    }, {
                    text: 'Igual ou Maior Pt.',
                    sortable: true,
                    dataIndex: 'maior',
                    width: 174,
                    field: {
                    xtype: 'textfield'
                        }
                    }],
                dockedItems: [{
                    xtype: 'toolbar',
                    items: [{
                        text: 'Novo',
                        icon: '../source/images/add.png',
                        handler: function(){
                            // empty record
                            store_pontuacao.insert(0, new Person());
                            rowEditing.startEdit(0, 0);
                        }
                    }, '-', {
                        itemId: 'delete',
                        text: 'Excluir',
                        icon: '../source/images/delete.png',
                        disabled: true,
                        handler: function(){
                            if (selection) {
                                store_pontuacao.remove(selection);
                            }
                        }
                    }]
                }]
            });
            grid2.getSelectionModel().on('selectionchange', function(selModel, selections){
                grid2.down('#delete').setDisabled(selections.length === 0);
            });

  2. Please review the API for the edit event:
    http://docs.sencha.com/ext-js/4-1/#!...ing-event-edit

    edit: function(ed, e) {
    Also .. what is the purpose for make an ajax call and loading the store on each edit?

    Scott.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,884
    Answers
    653
    Vote Rating
    440
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    Please review the API for the edit event:
    http://docs.sencha.com/ext-js/4-1/#!...ing-event-edit

    edit: function(ed, e) {
    Also .. what is the purpose for make an ajax call and loading the store on each edit?

    Scott.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    11
    Vote Rating
    0
    OtavioF is on a distinguished road

      0  

    Default


    I did it to update the store at each edit that i do. The problem is that i want to save all the data in one session, then save it at the Database.

    Now i have a problem when i insert the data, the grid updates but the values vanish, though it is saved in the session.
    How can i update the grid with the session's data without them disappear?

  5. #4
    Sencha User
    Join Date
    Oct 2012
    Posts
    11
    Vote Rating
    0
    OtavioF is on a distinguished road

      0  

    Default


    I've already solved my problem.

    Thanks Scott.

Thread Participants: 1

Tags for this Thread