I want to bind the count of datasource(itemsource) for xamGrid in Page style. So tried in this way:
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Cell.Row.Manager.Rows.Count}"
but that is the number of rows in one page, same as pagesize, not the total count of datasource.
What's the right path for this case?
Or if xamGrid dataContext is viewmodel which has a property say TotalCount, how to bind it to a textbox in PageStyle?
Hello,
I have tested the sample application that I attached with my previous post with PagedCollectionView and it seems to work as it supposed to. The Count property of the PagedCollectionView gets the amount of the records which are currently in view. When I change the items source of my application to PagedCollecitonVeiw and use the binding you mentioned I get “20” in the TextBlock. In order to show the count of all the records you can use TotalItemCount property instead. The TextBlock will look like this:
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding
RelativeSource={RelativeSource TemplatedParent},
Path=Parent.Owner.Grid.ItemsSource.TotalItemCount,
StringFormat='There are {0:N0} Rows in the XamGrid'}"/>
If you have any further questions please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
I want to display summary like below:
Displaying X through Y out of Z records.
e.g on first page,it will show
Displaying 1 through 25 out of 29 records.
considering pageSize set to 25.
and on second page it will show
Displaying 26 through 29 out of 29 records.
Please suggest.
Hi,
Your best bet is probably to use a ValueConverter in the the binding for display text.
You'd then calculate the text based on the current page, the totalItemCount, and pageSize
-SteveZ
We tried using IValueConverter to construct summarytext as below. <Style x:Key="CustomSummaryStyle" TargetType="igPrim:SummaryRowCellControl"> <Setter Property="FontSize" Value="11" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Right"/> <Setter Property="Background" Value="{StaticResource SummaryRowBackgroundBrush}"/> <Setter Property="BorderBrush" Value="{StaticResource CellItemNormalBorderBrush}"/> <Setter Property="BorderThickness" Value="0,0,0,0"/> <Setter Property="Padding" Value="7,3"/> <Setter Property="SummaryDisplayTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="{Binding Converter={StaticResource RowCountConverter}}"/> </DataTemplate> </Setter.Value> </Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="igPrim:SummaryRowCellControl"> <Grid> <VisualStateManager.VisualStateGroups> ............................ </VisualStateManager.VisualStateGroups> <Border x:Name="AddNewRowElem" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"> <!--<Rectangle Height="1" VerticalAlignment="Top" Fill="#7FFFFFFF" />--> <StackPanel x:Name="SummaryDisplay" HorizontalAlignment="Right" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"/> </Border> <Rectangle Fill="Transparent" Stroke="{StaticResource CellItemSelectedBorderBrush}" StrokeThickness="1" x:Name="ActiveRect" Visibility="Collapsed"></Rectangle> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>And we are using this "CustomSummaryStyle" in SummaryRowSettings of Xamgrid ColumnLayout as below. <ig:XamGrid x:Name="xamGridFL" PageIndexChanging="xamGridFL_PageIndexChanging" RowExpansionChanging="xamGridFL_RowExpansionChanging" AutoGenerateColumns="False" > <ig:XamGrid.Columns> <ig:ColumnLayout Key="SolutionElements" HeaderVisibility="false" ColumnLayoutHeaderVisibility="Never" DeleteKeyAction="None" > <ig:ColumnLayout.RowSelectorSettings> <ig:RowSelectorSettingsOverride Visibility="Collapsed" /> </ig:ColumnLayout.RowSelectorSettings> <ig:ColumnLayout.Columns> <ig:TextColumn HeaderText="{Binding Path=Description, Key="SECodeDescription" Width="0.29*" MinimumWidth="10"> <ig:TextColumn.SummaryColumnSettings> <ig:SummaryColumnSettings > <ig:SummaryColumnSettings.SummaryOperands> <ig:CountSummaryOperand IsApplied="True"> </ig:CountSummaryOperand> </ig:SummaryColumnSettings.SummaryOperands> </ig:SummaryColumnSettings> </ig:TextColumn.SummaryColumnSettings> </ig:TextColumn> </ig:ColumnLayout.Columns> <ig:ColumnLayout.PagerSettings> <ig:PagerSettingsOverride AllowPaging="Bottom" PageSize="25" Style="{StaticResource DefaultPagerStyle}"/> </ig:ColumnLayout.PagerSettings> <ig:ColumnLayout.SummaryRowSettings> <ig:SummaryRowSettingsOverride Style="{StaticResource CustomSummaryStyle}" AllowSummaryRow="Bottom" SummaryScope="ColumnLayout" SummaryExecution="AfterFilteringBeforePaging" /> </ig:ColumnLayout.SummaryRowSettings>and code for RowCountConverter is as below: public class RowCountConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string summaryText; int totalNestedRowsCount, currentPageIndex; int x = 0, y = 0; int nestedGridPageSize = LifeCycle.NestedGridPageSize; bool success = int.TryParse(((Infragistics.SummaryResult)(value)).Value.ToString(), out totalNestedRowsCount); if (!success) { return value; } currentPageIndex = totalNestedRowsCount <= nestedGridPageSize ? 0 : LifeCycle.NestedGridPageIndex; int totalPages = totalNestedRowsCount / nestedGridPageSize; int roundedRecords = totalPages * nestedGridPageSize; int LastPageRecords = totalNestedRowsCount - roundedRecords; if (currentPageIndex == 0) //After applying column filter { x = 1; y = totalNestedRowsCount >= nestedGridPageSize ? nestedGridPageSize : totalNestedRowsCount; } else { x = currentPageIndex == 1 ? currentPageIndex : ((currentPageIndex - 1) * nestedGridPageSize) + 1; y = currentPageIndex <= totalPages ? currentPageIndex * nestedGridPageSize : roundedRecords + LastPageRecords; currentPageIndex = 0; } if (y == 0) x = 0; summaryText = " Displaying records " + x + " through " + y + " out of " + totalNestedRowsCount; return summaryText; } }But the problem with this is that,As the row is expanded in xamgrid and we change the page number on nested grid, XamGrid's PageIndexChanging event updates the CurrentPageIndex.But the RowCountConverter also gets raised for previous expanded row and in result "CurrentPageIndex" for previously expanded row also gets updated with newly expanded row's page index and therefor shows the wrong summary count.
Please advice.