1. #1
    Sencha User
    Join Date
    Apr 2010
    Posts
    3
    Vote Rating
    0
    fedegar33 is on a distinguished road

      0  

    Default Updating cell value in grid (cellclick problem)

    Updating cell value in grid (cellclick problem)


    Hi, im having a problem setting a value in a grid (in the cellclick event). I searched in the grid faq and on many forums but not found nothing about this problem.

    Well, here is my code:

    Code:
    var myData = [
                ['Func 1', '2', '3', '1', '5', 0],
                ['Func 2', '2', '3', '2', '5', 0],
                ['Func 3', '2', '3', '3', '5', 0],
                ['Func 4', '2', '3', '4', '5', 0],
                ['Func 5', '2', '3', '5', '5', 0],
                ['Func 6', '2', '3', '6', '5', 0]
            ];
            
            var store = new Ext.data.ArrayStore({
                fields: [
                   {name: 'cajero'},
                   {name: 'hora2'},
                   {name: 'hora3'},
                   {name: 'hora4'},
                   {name: 'hora5'},
                   {name: 'horas', type: 'int'}
                ]
            });
            
            function myRenderer(val) {
                return '<span style="font-weight:bold;">' + val + '</span>';
            }
    
    
            store.loadData(myData);
            
            var grid = new Ext.grid.GridPanel({
                store: store,
                sm: new Ext.grid.CellSelectionModel({singleSelect:true}),
                cm: new Ext.grid.ColumnModel([
                    new Ext.grid.RowNumberer(),
                    {
                        id       : 'cajero',
                        header   : 'Cajera', 
                        width    : 50, 
                        sortable : false, 
                        dataIndex: 'cajero',
                        renderer: myRenderer
                    },
                    {
                        id       : 'hora2',
                        header   : '06:30', 
                        width    : 50, 
                        sortable : false, 
                        dataIndex: 'hora2'
                    },
                    {
                        id       : 'hora3',
                        header   : '07:00', 
                        width    : 50, 
                        sortable : false, 
                        dataIndex: 'hora3'
                    },
                    {
                        id       : 'hora4',
                        header   : '07:30', 
                        width    : 50, 
                        sortable : false, 
                        dataIndex: 'hora4'
                    },
                    {
                        id       : 'hora5',
                        header   : '08:00', 
                        width    : 50, 
                        sortable : false, 
                        dataIndex: 'hora5'
                    },
                    {
                        id       : 'horas',
                        header   : 'Horas', 
                        width    : 50, 
                        sortable : false, 
                        dataIndex: 'horas'
                    }
                ]),
                stripeRows: false,
                autoExpandColumn: 'cajero',
                height: 350,
                width: 600,
                title: 'Recursos',
                // config options for stateful behavior
                stateful: false,
                id: 'grid',
                stateId: 'grid',
                listeners: {
                    //Manejo el click de una celda
                    cellclick: function(grid, rowIndex, columnIndex, e) {
                        cont = 0;
                        var record     = grid.getStore().getAt(rowIndex);
                        var selCell    = grid.getSelectionModel().getSelectedCell();
                        var fieldName  = grid.getColumnModel().getDataIndex(selCell[1]);
                        var cantCols   = grid.getColumnModel().getColumnCount();
                        var cellValue  = parseInt(record.get(fieldName));
                        var cellActual = Ext.get(grid.getView().getCell(rowIndex, columnIndex));
                        
                        if (columnIndex == 1 || columnIndex == 6) {
                            return false;
                        }
                        
                        cellActual.toggleClass('error');
                        cont = 0;
                        
                        for (var i = 1; i < cantCols; i++) {
                            if (Ext.get(grid.getView().getCell(rowIndex, i)).hasClass('error')) {
                                cont++;
                            }
                        }
                                            //record.set('horas', cont);
                        record.data['horas'] = cont;
                                            record.commit();
    
                    }
                }
            });
            grid.render('grilla');
    What i want is when i click one cell it change its css class and update "horas" value in the row that the cell is contained. The problem comes when the record.commit() method is called (or when i use record.set() method). I need to click twice in the cells to change its class and when i click in another cell the previous one "loses" the css class that its supossed to have.

    I suspect that i am doing something wrong but dont know what.

    Thanks in advance! (and sorry for my english)

    Delete this, wrong subforum, sorry.
    Last edited by fedegar33; 2 Nov 2011 at 10:04 AM. Reason: Delete post, wrong subforum

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,703
    Vote Rating
    749
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I have moved to the appropriate forum.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread

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