Hi,
sometimes when I set the ActiveRecord of the Grid, the Grid selects the wrong record... It seems that the error occures after I selected the last record and then go up the list, step by step...
Sample:I have 50 records and select the last, then I go back by setting the ActiveRecord Property, at the 20th record it doesn't go to record no. 19! Instead it goes to the 50 one...
The RecordActivating Event triggers 4 to 5 times for this step!
BTW: the position of the record where the error occures seems to depend on the height of the grid.
Kind RegardsFlorian Sundermann
Hi Florian,
I've had some issues with that property as well. The utility method below might be somewhat redundant for the next release (7.2 Beta is over 2 months old, if I recall correctly), but does it's job ok for now:
/// <summary> /// Selects and activates a given record of a grid. /// </summary> public static void SelectRecord(XamDataGrid grid, Record record) { //remove current selections grid.SelectedItems.Records.Clear(); grid.ActiveRecord = null; grid.ActiveRecord = record; record.IsSelected = true; }
/// <summary> /// Select the <see cref="DataRecord"/> that represents a given /// data item. /// </summary> /// <param name="grid">The grid to be processed.</param> /// <param name="dataItem">The bound item to look for.</param> /// <returns>True if the grid provides any records which could be /// selected. If the grid is empty, false is returned.</returns> public static bool SelectRecordForItem(XamDataGrid grid, object dataItem) { DataRecord record = grid.GetRecordFromDataItem(dataItem, false); if (record != null) { SelectRecord(grid, record); return true; } else { return false; } }
Hope it'll work. Cheers!
Philipp
That doesn't work ;-(
If I remove the line "ActiveRecord = record" the selection moves right (so I've got the right records) but no chance to move the active record as I want to.
That is quite strange... Is it possible that you're setting ActiveRecord in a grid-related event? However: I've seen in the log file of my helper class that my method once also had another, quite ugly line of code at the end of the method which I removed in the meantime as it's working for me now without it:
public static void SelectRecord(XamDataGrid grid, Record record) { //remove current selections grid.SelectedItems.Records.Clear(); grid.ActiveRecord = null; grid.ActiveRecord = record; record.IsSelected = true; //HACK This is plain horrible record.DataPresenter.Focus(); }
If that does the trick: what version of NA are you using? If it's 7.2 Beta, I'd be very interested in a feedback from the Infragistics staff, as explicitly setting focus might produce side effects with other controls...
Kepp me posted
No this also don't work...I also tried to set "record.IsActive = true;" but after this line the IsActive Property is false!!!7.2? Am I missing something? At the moment I use 7.1
BTW: record.DataPresenter.Focus() == grid.Focus()
Florian
Hmm, I'm running out of ideas
Regarding 7.2: I'm referring to the beta: http://ko.infragistics.com/hot/wpf-beta.aspx
If you have a sample that demonstrates the issue, I could check whether the issue is the same with the Beta. I'll send you a private message with my email address in case you want to send me something...
Version 7.2 solved the problem for me ;)
Thx