S. Moreno
S. Moreno

Reputation: 536

get value from gridpanel with extJS

I have one gridpanel with some rows. I want to show in alert the código value if you double click in that row.

enter image description here

With these code only i get the value from the cell where i double clicked (if i click on "tipo" i get "final" or "borrador" but not the codigo value) This is my listener:

    listeners: {
        'rowdblclick': function (view, record, tr, columnIndex, e) {
            var cell = e.getTarget('.x-grid-cell-inner');
            if (!cell) {
                return;
            }
            alert(cell.innerHTML)
        }
    },

i tried with this codes but still failing (null)

            'rowdblclick': function(view, rowIndex, colIndex, item, e, record){
                alert(grid.getStore().getAt(rowIndex).get('codigo'));
            }   

            'rowdblclick': function(view, rowIndex, colIndex, item, e, record){
                                        alert(record.get('codigo'));
            }   

What i need to obtain the codigo value from the row where you double click?

Thank you in advance.

Upvotes: 0

Views: 1270

Answers (1)

Alex Tokarev
Alex Tokarev

Reputation: 4861

For the future, it is always good to indicate which Ext JS version you are using. It is entirely not obvious just from your code.

That said, there was no rowdblclick event for Views in 4.x line, and thus it must be either 3.x or 5.x. I will assume it is 5.x.

The reason your code is not working is wrong parameters your event handler expects in second and third snippets. The first one had the right signature, so you should use it:

listeners: {
    // You don't have to declare all arguments, just those you need
    rowdblclick: function(view, record) {
        var codigo = record.get('codigo');

        alert('Codigo: ' + codigo);
    }
}

To get the data, you never poke in rows and cells. Rows and cells are only presentation for the data contained in the Store bound to the Grid. The event handler above receives the record object for the row that was clicked, and that record contains the data values for that row.

Upvotes: 1

Related Questions