javascriptdojodgriddstore

Intercepting the data returned from a Dojo dgrid selection


I'm using Dojo 1.10, dgrid, and dstore.

I have a grid that mixes in OnDemandGrid and Selection. When I click on a row, Selection emits a 'dgrid-select' event along with the data. Is there any way (e.g., callback function, subclass override) to get hold of the data after selection but before the event is fired? I'd like to manipulate the selected data before the event receiver gets it.


Solution

  • In the dgrid Selection.js module, there's a function called "_fireSelectionEvent". In this function, you receive a type of event that can be 'select' or 'deselect'.

    You probably want to override this function whenever a 'select' event is fired. The var queue contains all data related to the selected/deselected rows and is later assigned to the event object that is fired by the emit. You can manipulate the data that there.