ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: argo on August 01, 2014, 07:29:20 am

Title: properly capture when selection changes are completed
Post by: argo on August 01, 2014, 07:29:20 am
I've searched in the forum assuming this must have been answered before but I couldn't find anything relevant.

I need to know when the the grid has completed all tasks associated with changing a selection. I first tried to use rowSelect but the problem was that when an already selected row is ctrl-clicked, it becomes unselected which changes the set of selected rows but the rowSelect event doesn't fire. Or if someone SHIFT-clicks a set of rows, then the rowSelect fires for every single row even though the user's action (at least from their perspective) was only to make one selection change.  But if I use rowClick, then when someone uses CTRL-A to select all (or I make selections programmatically without a 'click') the rowClick event isn't triggered. And if I use a combination of rowSelect and rowClick, then I get multiple event triggers when someone goes from having several rows selected to only 1.

Basically, when pqgrid is done making all the changes to a selection, I want to fire a method once. It only needs to fire once per change in selection. I'm struggling to find the right combination of the available events to do this. I tried debouncing the multiple function calls but didn't have any success.

Any thoughts?
Title: Re: properly capture when selection changes are completed
Post by: paramvir on August 01, 2014, 09:35:18 am
Quote
I first tried to use rowSelect but the problem was that when an already selected row is ctrl-clicked, it becomes unselected which changes the set of selected rows but the rowSelect event doesn't fire

There is a rowUnSelect event whenever a row is deselected.

Quote
Or if someone SHIFT-clicks a set of rows, then the rowSelect fires for every single row even though the user's action (at least from their perspective) was only to make one selection change.

You are right, a single rowSelect event makes more sense in this case. It would be addressed in next version.

Quote
But if I use rowClick, then when someone uses CTRL-A to select all (or I make selections programmatically without a 'click') the rowClick event isn't triggered.

When CTRL-A is pressed, all selections are available in rowSelect event as ui.rows which is an array of selections.

http://paramquery.com/pro/api#event-rowSelect
http://paramquery.com/pro/api#event-rowUnSelect
Title: Re: properly capture when selection changes are completed
Post by: argo on August 01, 2014, 10:00:50 am
Thanks for the reply. That's great to hear that it'll be addressed in next release.

One suggestion I'd make is to introduce a new event called "selectChange" and have that be a universal event that fires one time whenever the selection is modified (adding row(s)/cell(s), removing row(s)/cell(s), select all, select none, etc). This would give a very easy hook into the grid to know when the work of changing a selection has been complete. It'd basically be the correct combination of rowSelect and rowUnselect combined into one event handler.
Title: Re: properly capture when selection changes are completed
Post by: paramvir on August 01, 2014, 07:07:23 pm
Thanks for nice suggestion. It's a small change and it has been added in next version.