PDA

View Full Version : Grid Click event handler



pex
17 Aug 2007, 4:11 AM
My grid has a column called 'count' which is rendered as anchors containing integer values. Eg.


<a href="#" class="count_anchor">53</a>

I have added a listener to these anchors as follows:



myGrid.on("click", this.onCountClick, this);
onCountClick: function(e){
if (Ext.get(e.getTarget()).hasClass('count_ancho') ) {
e.stopEvent();
console.log(this);
}
}

This works fine. However, what I want is to pass additional information to the onCountClick function, so that it can determine what anchor was clicked. I thought of adding it to the anchor's class, but this seems oldschool.

What Ext way is there to pass custom objects to the listeners' handler?

Thanks in advance

para
17 Aug 2007, 6:52 AM
If it helps, you can use the grid's selection model to get the row/cell that was clicked/selected.


if(this.getSelectionModel().hasSelection()) {

var cell = this.getSelectionModel().getSelectedCell();
// cell == [rowIndex, colIndex]

var record = this.getSelectionModel().selection.record;


Is this what you're looking for?

(The only issue is I'm not sure if clicking an anchor in a grid will cause the selection of the grid cell).

pex
17 Aug 2007, 7:44 AM
This works yes, thank you - and you were also right about the selection of the grid row :)