susparsy
susparsy

Reputation: 1046

Get values from grid

I added an actioncolumn to my grid, and i am trying to get a grid value when it is pushed.

this is my actioncolumn:

xtype: 'actioncolumn',
width: 30,
sortable: false,
menuDisabled: true,
items: [{
    icon: 'images/refresh16x16.png',
    scope: this,
    handler: this.onBidHistoryGridlClick
}

This is my listener:

onBidHistoryGridlClick: function(record, grid, rowIndex){
    alert(grid.getStore().getAt(rowIndex).column_name);
}

This doesnt work.

pic

Any ideas?

Upvotes: 1

Views: 3181

Answers (2)

JustBeingHelpful
JustBeingHelpful

Reputation: 18990

In addition to @rixo's answer, you may need to use the "data" attribute depending on the context (event handler callback function):

                handler: function (grid, rowIndex, colIndex) {
                    var rec = grid.getStore().getAt(rowIndex).data;
                    alert(rec.toSource());  // this only works in Mozilla Firefox
                    var rec_col_val = grid.getStore().getAt(rowIndex).data.col_name;
                    alert(rec_col_val);

Upvotes: 0

rixo
rixo

Reputation: 25041

You've got the record in the listener arguments, use it!

record.get('column_name')

You were probably close with your own tentative, but you forgot that what you get from the store is a record, not a raw data object. So this would rather have been:

grid.getStore().getAt(rowIndex).get('column_name')

Update

You've got your handler's arguments wrong (check the docs). This should be:

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

Upvotes: 3

Related Questions