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
There is no child grid. There is only one XamGrid and this grid splits your data into groups. When you expand these groups it adds the paging controls as part of the group. The XamGrid.PagerSettings controls the pager settings for every pager within the grid, so it's all shared. I'm not sure what your styles look like but the only way you can style the paging controls is to create styles for PagerCellControl and then use the code I provided in my last post in order to apply the style to the child pagers. In my code I used PagerCellsPanel so you'll need to go 1 extra step down in the VisualTree in order to get PagerCellControl. PagerCellControl is a child of PagerCellsPanel.
I have tried out the method of getting the child of the pagerscellspanel i.e pagercellcontrol and tried to apply the styles to it from the c#.
I have two styles basically in the resource dictionary one is for the parent pager and one is for the child pager but none of them worked.
if you can look into this it would be great
foreach (var panel in pagerPanels) { if (panel.Visibility == System.Windows.Visibility.Visible && panel.Row != null && panel.Row.Manager.ParentRow != null) { var pagercellcontrol = panel.Children.OfType<PagerCellControl>().FirstOrDefault(); //panel.Visibility = System.Windows.Visibility.Collapsed; pagercellcontrol.Style = Resources["pccChild"] as Style; var pagercontrol = panel.Children.OfType<PagerControl>().FirstOrDefault();//Tried directly getting the pager control to apply the styles pagercontrol.Style = Resources["pccChild"] as Style; panel.Row.ColumnLayout.PagerSettings.AllowPaging = PagingLocation.Bottom;//tried to over ride the styles }
POC code for ref:http://1drv.ms/1RnbZ4I
I took a look at your updated sample. There is no style called "pccChild" in the sample so the code "Resources["pccChild"] as Style" is going to return null. I think you meant to use "childStyle" instead.
pagercellcontrol.Style = Resources["childStyle"] as Style;
That should work. The other code you have after this is not necessary.
Sorry
in the code it is x:Key="childStyle". I tried updating but it is still not working. If possible can you post the working solution please
Here's the sample. You can see that your styles are working because the pager control has been replaced with some export buttons.
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