Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Dave on Jul 16, 2008 11:26
open dhtmlx forum
onSelectStateChanged

This event handler does not appear to be useful to identify rows that have been deselected, only rows that have been just selected.

Sooo, short of iterating through all the rows of the grid upon the triggering of this event, or maintaining an array of selected rows and iterating through that array to remove the entry of rows not currently selected (not an efficient process, especially with multiselect enabled), is there an efficient way to identify a row or rows that have been deselected?

Say for instance, I want to use a custom style or image to indicate selected rows - I would then need to reset that style or flag when a row becomes deselected.
Answer posted by Support on Jul 17, 2008 05:29
In case of single selection it can be done by onBeforeSelect event which provides IDs of row which will be selected and one which was selected previously.
In case of multiple selection the situation is a bit complex, it possible to get necessary info by complex event manipulation , but you can made next change
    dhtmlxgrid.js, line 1267
        this.callEvent("onSelectStateChanged", [afinal]);
change to
    this.callEvent("onSelectStateChanged", [afinal,initial]);
as result event handler will receive two lists , first will contain currently selected IDs, second will contain previously selected IDs

The same update will be added to the next version of  grid.