Hi,
There is a "ScrollIntoView" method ? like the one used with the WPF ListView ?
Also, is there a way to reset the scrollbar on the top ?
Thanks
this.xamDataGrid.BringRecordIntoView(myRecord);
Joe,
I can't get this to work correctly. The grid does scroll, but the record is rarely visible. Instead, I see either the group by record header or part of the label header.
I have a NEXT button which locates, activates and brings the next record into view.
Here's a blow-by-blow description of what I see as I hit the next button repeatedly, starting from the last child record in a group followed by another group containing 7 child records and that next group is not visible on the screen:
1. The grid scrolls a little, bringing the next group into view just a little. The group is expanded. All I can see is the group by header and about 1/3 of the label row - not even enough to read the labels.
2. The grid jumps in a "large increment". I can now see the first record, the 2nd record (correctly selected) and 1/2 of 3rd record.
3. The grid jumps again and I can now see the 3rd record (it's selected), the 4th record and entire 5th record.
4. No scrolling takes place. The selection moves down to the 4th record as expected.
5. No scrolling takes place. The selection moves down to the 5th record as expected.
6. The grid jumps. I can see 6th record (selected), the 7th record, the GBR for the next group and half of the GBR for the group after that.
7. No scrolling takes place. The selection moves down to the 5th record as expected.
8. The next GBR opens, but I can only see it and the full label row inside it. I can't see the 1st record in it, which is selected.
9. The grid jumps up and I can see the 2nd record (selected) and the 3rd record.
and so on... Of course, the users aren't too happy about this behavior.
Any ideas?
Thanks.
Hi Todd -
Repeatedly hitting the Next button within a top level GBR seems to work as expected here. I did notice a bit of strangeness hitting the Previous button when 'previous records' are scrolled out of view. But 'Next' worked fine for me.
Can you post a VS sample with your data so I can try to dup it in your environment?
JoeM
Sure, here it is. I have two levels of grouping. This navigation works within a single top level grouping. By design, it stops at the last GBR within a top-level group.
#region Grid Navigating and Activating records
delegate void RecordMethod(Record rec);
// This indirection may not be required, but it was the solution to a related topic on the Infrgistics forum.private void ActivateRecordHelper(Record rec){ rec.IsActive = true; rec.IsSelected = true; rec.DataPresenter.BringRecordIntoView(rec);}
private void ActivateRecord(Record rec){ this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new RecordMethod(this.ActivateRecordHelper), rec);}
private void NextPatient_Click(object sender, RoutedEventArgs e){ NavigateToNextPatient();}
private void PreviousPatient_Click(object sender, RoutedEventArgs e){ NavigateToPreviousPatient();}
private GroupByRecord NextParent(Record rec){ // Find parent GroupByRecord p = rec.ParentRecord as GroupByRecord;
if (p != null) { // Find grandparent GroupByRecord g = p.ParentRecord as GroupByRecord;
if (g != null) { int c = g.ChildRecords.Count; int i = p.Index; // Index into the grand parent collection.
// If there are any records after the current record, return the next one. if (i < c - 1) { GroupByRecord np = g.ChildRecords[i + 1] as GroupByRecord; return np; }
// We're out of parents at this level, find the next grandparent return NextParent(p); } }
return null;}
private GroupByRecord PreviousParent(Record rec){ // Find parent GroupByRecord p = rec.ParentRecord as GroupByRecord;
// If this is not the first record, return the previous one. if (i > 0) { GroupByRecord np = g.ChildRecords[i - 1] as GroupByRecord; return np; }
// We're out of parents at this level, find the previous grandparent return PreviousParent(p); } }
private DataRecord NextSibling(DataRecord rec){ // Find parent GroupByRecord p = rec.ParentRecord as GroupByRecord;
if (p != null) { // If there are child records after this one, return the next one. int c = p.ChildRecords.Count; int i = rec.Index; // Index into the grand parent collection.
// If there are any records after the current record, return the next one. if (i < c - 1) { DataRecord nr = p.ChildRecords[i + 1] as DataRecord; return nr; } }
private DataRecord PreviousSibling(DataRecord rec){ // Find parent GroupByRecord p = rec.ParentRecord as GroupByRecord;
if (p != null) { // If there are child records before this one, return the previous one. int i = rec.Index; // Index into the grand parent collection.
if (i > 0) { DataRecord nr = p.ChildRecords[i - 1] as DataRecord; return nr; } }
#endregion
#region JUMP to Next/Previous record in the grid
private void NavigateToNextPatient(){ DataRecord rec = XamPatientPicker.ActiveRecord as DataRecord;
if (rec != null) { DataRecord newRec = NextSibling(rec);
if (newRec == null) { // Get current group by rec GroupByRecord oldGbr = rec.ParentRecord as GroupByRecord;
GroupByRecord p = NextParent(rec);
if (p != null) { newRec = p.ChildRecords[0] as DataRecord;
if (newRec != null) oldGbr.IsExpanded = false; // Collapse previous working group } }
if (newRec != null) ActivateRecord(newRec); }}
private void NavigateToPreviousPatient(){ DataRecord rec = XamPatientPicker.ActiveRecord as DataRecord;
if (rec != null) { DataRecord newRec = PreviousSibling(rec);
GroupByRecord p = PreviousParent(rec);
if (p != null) { int c = p.ChildRecords.Count; newRec = p.ChildRecords[c - 1] as DataRecord;
Can you give me the exact code that gets executed with each click of the 'Next' button? I'll try it here (or send me a complete project if it's convenient)
Joe