Listen for the GridEvent.GRID_CLICK event instead. The GridEvent will have the column index in it. We redispatch all mouse events on the DataGrid as GridEvents.
You are right!
I thougt that GRID_Click works only on cells and not on the headers.
Thanks for your quick help!
Kevin, on a related topic. I've "change" event on grids/lists in the past. That appears to have gone away with spark dataGrid.
What is the best way to select a row? what is the difference between selectionChange and GridClick?
Do you mean programmatically selecting a row? or detecting when a user has just selected a row?
If the first, there are a bunch of selection API's available on DataGrid. I'd take a look at the documentation and let me know if you have further questions.
If the second, selectionChange is dispatched whenever the selection is changed via user interaction (mouse click, key stroke, etc...). The gridClick event is dispatched only when a mouse click happens in the DataGrid, no relation to the selection changing.
Hope that helps.
Just trying to sort out in my head which one to use when the user clicks/taps a row to select it, not programmatically. Both selectionChange and gridClick fire when the user clicks/taps in the Grid and they both set the selectedItem property, so it is just a little gray which one to use.
I'll did deeper into the docs on GridEvent vs. GridSelectionEvent, but not sure the use case for each one.
Yes, there are a bunch of selection APIs, which only begs the question: which make the most sense to use when. I was more curious at this point.
Appreciate the help.