Hi Team,
I am working on the Xam Grid control. Xam grid Contains a custom pager with some styles.
When a group by is done on the parent grid control. All the child grid controls formed as a result of group by is also inheriting the parent pager settings.
I dont want the parent pager styles to the child. I tried in the following way to remove the styles. But the it is applying for both the child and parent.
<igGrid:XamGrid HorizontalAlignment="Stretch" Grid.Row="1" x:Name="igGrid" AutoGenerateColumns="False" Loaded="igGrid_Loaded" GroupByCollectionChanged="igGrid_GroupByCollectionChanged" >
private void igGrid_GroupByCollectionChanged(object sender, GroupByCollectionChangedEventArgs e) { var childgrid= sender as XamGrid; if (e.NewGroupedColumns.Count > 0) { childgrid.GroupBySettings.GroupByColumns.Grid.PagerSettings.AllowPaging = PagingLocation.None; //((XamGrid)childgrid.GroupBySettings.GroupByColumns.Grid.Parent).PagerSettings.AllowPaging = PagingLocation.Bottom; } childgrid.PagerSettings.AllowPaging = PagingLocation.Bottom; }
Is there any way that it can be done only the child grids?
Hi Manoj,
Pager settings can be set on a per ColumnLayout fashion but when you groupby columns, rows under each grouping are not considered as child rows since they still use the same ColumnLayout as they did without the groupby. In order to hide the pager stuff for grouped rows you'll need to use a style on the PagerCellsPanel which hides it. Something like this:
<Style TargetType="{x:Type ig:PagerCellsPanel}"> <Setter Property="Visibility" Value="Collapsed"/> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Row.Manager.ParentRow}" Value="{x:Null}"> <Setter Property="Visibility" Value="Visible"/> </DataTrigger> </Style.Triggers> </Style>
Hi Rob,
Thanks for the quick reply. I Tried your solution in my silverlight project but i am not able to get the thing done.
I have created sample poc for your reference. If you can replicate the behaviour of our code in my sample it would be great.
sample code: http://1drv.ms/1SQhBYs
Regards,
manoj
For some reason I thought you were using WPF so I wrote that style with triggers but Silverlight doesn't support triggers so that won't help. Silverlight makes things a bit difficult so what I ended up doing was handling the RowExpansionChanged event and searching for the PagerCellsPanel in there. When I found the panel I'd check to see if it was a child pager and then hide it. Here is the code I used:
private void igGrid_RowExpansionChanged(object sender, RowExpansionChangedEventArgs e) { if (e.Row.IsExpanded) { Dispatcher.BeginInvoke(new Action(() => { var rowsPanel = e.Row.Control.Owner as RowsPanel; var pagerPanels = rowsPanel.Children.Where(x => x is PagerCellsPanel).Cast<PagerCellsPanel>(); foreach (var panel in pagerPanels) { if (panel.Visibility == System.Windows.Visibility.Visible && panel.Row != null && panel.Row.Manager.ParentRow != null) panel.Visibility = System.Windows.Visibility.Collapsed; } })); } }
Thanks for the code. is there any way that i can set the styles for the PagercellsPanel instead of going completely off.
I mean different style for child pager and parent pager.
regards,
Manoj
Unfortunately no. They both use the same PagerCellsPanel type and using a style there is no way to differentiate between a child pager and parent pager. The only way to differentiate is through the PagerCellsPanel.Row.Manager.ParentRow property. If there is a ParentRow that means the pager is a child pager. This ParentRow property does not fire property change notifications so binding to it doesn't do anything. That's why I did this in code. And that's why I had to use a Dispatcher, because initially the Row property is null but it is later changed to a valid row. The Dispatcher is meant to delay the code execution until after the Row property is valid.