Hello,
I have a master GridView and a details GridView in a RowDetailsTemplate. The master GridView is set to use FrozenColumnCount and works when the master GridView is scrolled horizontally as I expected, meaning the specified columns do not scroll.
The detail GridView is also set to use FrozenColumnCount. But when I scroll at the master GridView level, the frozen columns in the detail GridView scroll anyway.
Is there a way to scroll at the master GridView level, and have the detail GridView respect the FrozenColumnCount setting?
Any suggestions?
Thanks in advance!
Scott
4 Answers, 1 is accepted
Such kind of functionality isn't available because the master grid detects the content defined within its RowDetailsTemplate not like a grid, but just as a content control. Therefore, there is no way for the master grid to respect the detail's grid FrozenColumnCount setting.
Regards,
Martin Vatev
Telerik
Hello,
I understand the content control vs grid issue. I wonder if there is a workaround along another line:
1 - set details AreRowDetailsFrozen to True so scrolling at the master level does nothing with the content scroller
2 - Get the master grid scrollbar
ScrollBar verticalScrollBar1 = this.EquipmentGrid.ChildrenOfType<ScrollBar>().Where(b => b.Name == "PART_VerticalScrollBar").FirstOrDefault();
3 - Set an event on the master grid scrollbar:
verticalScrollBar1.ValueChanged += new RoutedPropertyChangedEventHandler<double>(verticalScrollBar1_ValueChanged);
4 - Then push through the scrollbar position to the detail grid's GridViewScrollViewer.
(this.IntervalRadGridView.ChildrenOfType<GridViewScrollViewer>().FirstOrDefault()).ScrollToHorizontalOffset(e.NewValue);
I already do this to synchronize the scrolling of a non-detail grid with the master grid, and it works fine. But I can't seem to get it to work on the detail grid.
Can you see an approach where a workaround like this might succeed? Any ideas would be most appreciated.
Thanks,
Scott
For your convenience, I prepared an example to demonstrate how to achieve the desired behavior. Please take a look at the implementation and consider how this approach fits your scenario. Keep in mind that this is some kind of customization which is not fully tested.
I hope that this helps. Should you have any other questions, do not hesitate to contact us.
Regards,
Martin Vatev
Telerik
I hope that this helps. Should you have any other questions, do not hesitate to contact us.
Thank you so much for the help! It's working now.
Note to others: the ScrollBar was not being built because my ActualWidth and actualHeight were 0. I forced a Measure and Arrange first and all began working:
EquipmentGrid.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
EquipmentGrid.Arrange(new Rect(0, 0, EquipmentGrid.DesiredSize.Width, EquipmentGrid.DesiredSize.Height));
Thanks again! I'd have been stuck without the working example to dissect!