Hi,
Users have reported unexpected behaivour when XamGrid is bound to a dynamically updating collection and sorting/grouping settings cause new items to appear above the currently displayed rows (for those appearing below, no issues reported). This behaivour makes user open context menu on the unexpected item and it is obviously not what the want.
I cannot provide sample code yet this behaivour can be easily reproduced using WPF Samples Browser - XamGrid - Editing & Selection - Active Item:
- open the sample
- click on BONAP cell
- sort by Company TWICE
- Active item window shows Laurence Lebihan, and Active Item is out of visible area.
My understanding is that ActiveItem should always be kept in the visible area.
I am using the lastest available patch for 2015.2.
I tried to use ScrollCellIntoView as a workaround but failed. Is there any way to achieve the expected behaivour?
Alex
PS. UPDATE. I've run Xceed's grid sample and they do have aforementioned functionality implemented the way users expect - even when sorting/grouping changes selected item is kept in the view. Of course, it jumps a little inside the grid's rectangle, but this is OK compared to XamGrid's scrolling out of view completely.
Hello Alexander,
The xamGrid control doesn’t provide this functionality by default but you can handle the ColumnSorted event, reset the XamGrid ActiveItem and then ScrollCellIntoView(xamGrid.ActiveCell) to achieve your requirement.
I have attached a sample application for your reference.
Sincerely,
hi Svetla,
Thanks for your response.
However, suggested approach doesn't work when data is added after sorting/grouping changed thus still making xamGrid's behaivour unsuitable for our users.
I managed to handle it partially (for cases when no grouping present) by this piece of code execute whenever underlying collection is changed:
-----
if (AssociatedObject.ActiveCell != null)
{
var item = AssociatedObject.ActiveCell.Row.Data;
var c2 = AssociatedObject.ActiveCell.Row.Cells[AssociatedObject.ActiveCell.Column.Key];
AssociatedObject.ActiveItem = null;
AssociatedObject.ActiveItem = item;
AssociatedObject.ScrollCellIntoView(c2);
AssociatedObject.ActiveCell = c2;
}
----
This allows me to keep active cell in view (it is being scrolled to the first/last visible row depending on sorting order and added item's property values).
When grouping is on, this code doesn't work - selected cell is reset upon underlying collection's change.
In both cases, collection fires Reset event to reflect its massive changes.
I'd appreciate any ideas which would allow to keep active cell in grouping mode as well.
I have researched the issue when having grouped columns for you. Currently, this is the default behavior for the xamGrid control and there seems to be no good approach to work around it. I would suggest you to add a new product idea for changing this functionality at http://ideas.infragistics.com.
Submitting your idea will allow you to communicate directly with our product management team, track the progress of your idea at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. You can also link back to this thread for additional details.
Thank you in advance to submitting your product idea.