Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
740
Focus on active row
posted

Hello, 

I have a question which concerns the UltraGrid. 

We have an application which uses a UltraGrid. We would like to group and ungroup this grid.
This works fine. 

As an extension to this functionality we create groups programmatically. When we create such a group, it would be nice to keep the focus on the current active row.
To accomplish this i have added some code in een extensions module (so i can re-use it easily).
The call grd.KeepFocusSelectedWhenGroupedBy("code") should do this. 

This method hooks up 2 eventhandlers which will keep the focus on the currert active row when clicked on the button.
This also works when i drag and drop a column to the header. 

Everything works fine until i want to collapse the currently selected group with 1 mouse click (so where the active row is present).
When i double click the group collapses, but with 1 click it won't.

But the double click functionality is used for other purposes, so i can't use this. 

I have actually 2 questions:

1 - Is there another way to hold focus on the active row when grouping the data ?

2 - If not, can you modify my code so it will have this functionality ?

 I included my source code with sample data.

Kind regards,

Jacob

DataGridFocusTest.zip
  • 12480
    Offline posted

    Hi Jacob,

    The reason this is occurring is because setting a row as the active row causes that row to scroll into view. This includes expanding the group that the row is under if needed. When the user collapses this group, the active row is immediately reset, which causes the group to expand.

    There is no way to activate the row without it coming into view.

    What is the required behavior for when the user attempts to collapse the group containing the active row?

    Why is it necessary to maintain the active row in this way? If it is only to help the user keep track of the active row, then I believe the best solution is to tweak the solution so that it doesn't reset the active row when collapsing its parent group.

    Please let me know how you choose to proceed.