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.
No its not differentiation. I want apply styles from the backend based on parent or child like below.
private void igGrid_GroupByCollectionChanged(object sender, GroupByCollectionChangedEventArgs e) { var childgrid= sender as XamGrid; if (e.NewGroupedColumns.Count > 0) { childgrid.GroupBySettings.GroupByColumns.Grid.PagerSettings.Style = ResourceDictinoary.StyleName; } childgrid.PagerSettings.AllowPaging = PagingLocation.Bottom; }
Hi Kumar,
Were you able to get this working? Let me know if you have any further questions.
I only see that exception if I comment out the PagerTemplateChanger class I added to MainPage.xaml.cs. If you are running the sample I attached as is, with no changes, then it should work because the class is there. I just redownloaded the sample and ran it on a virtual machine I made running VS2010 with SL5 installed. The sample ran as expected and the pager templates were applied.
I am not able to run the solution. I am getting the below exception on load of the view.
The property 'ParentPagerTemplate' was not found in type 'Infragistics.Controls.Grids.Primitives.PagerCellControl'.
InnerException is null
I actually found a better way to handle this. Instead of using the RowExpansionChanged event and trying to force the style to change I created a set of attached properties that allow you to set what templates you want to use for parent pagers and child pagers. So now you just need to create an implicit style for PagerCellControl in your XAML and setup these attached properties. Take a look at the updated sample I attached for more info.
I tried the code. But unfortunetly it did not worked.
It looked like to work because of the following line:
<igGrid:PagerSettings AllowPaging="Bottom" PageSize="3" Style="{StaticResource childStyle}"/>
So it started showing same line for parent and child. I have updated the code further and kept only one Parent style which should be applied.
If you can make the below code working that would be great
reference Code: http://1drv.ms/1T9yzkV