This is a migrated thread and some comments may be shown as answers.

Items.ItemCount count not correctly, when grouping

4 Answers 659 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Birgit
Top achievements
Rank 1
Birgit asked on 09 Jun 2017, 07:29 AM

Hello

The ItemSource of my RadGridView is binded to a QueryableCollectionView in my ViewModel.

<telerik:RadGridView x:Name="radGridView"
                     GroupRenderMode="Nested"
                     ItemsSource="{Binding MyView, UpdateSourceTrigger=PropertyChanged}"    
                     AutoGenerateColumns="False"
                     ShowGroupPanel="True"
                     RowIndicatorVisibility="Collapsed"
                     IsReadOnly="True"
                     ShowSearchPanel="True">
<telerik:RadGridView.Columns>
...
</telerik:RadGridView.Columns>
</telerik:RadGridView>

 

I use Items.ItemCount to show the Count of Items in the RadGridView. It works great, also when I filter the GridView.  However when I use grouping, it works not correctly. It counts the groups instead of Items. 

<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Items.ItemCount, ElementName=radGridView}" TextAlignment="Right"/>

 

How can I get around this problem? I do not want to use the AggregateFunctions.

 

Thank you.

4 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 13 Jun 2017, 12:02 PM
Hello Birgit,

Rather than use the ItemCount property which returns the number of elements in the collection's PagedCollectionView which is the number of groups when the control is grouped, may I suggest that you use the Count property, which will return the total number of elements?

<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Items.Count, ElementName=radGridView}" TextAlignment="Right"/>

Please let me know if this works for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Birgit
Top achievements
Rank 1
answered on 13 Jun 2017, 12:09 PM

Hi Dilyan

<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Items.Count, ElementName=radGridView}" TextAlignment="Right"/>

 

Items.Count gives the total of Items, not the count of filtered Items.

In the meantime I have built my own control, which makes this correct.

 

0
Accepted
Dilyan Traykov
Telerik team
answered on 13 Jun 2017, 01:39 PM
Hello Birgit,

The Items.Count seems to provide the correct value once the control is filtered at my end. You can observe this in the images and sample project I've attached to my reply.

Please let me know if you observe a different result at your end. Of course, if you're happy with the custom control you've built, you're free to use that as well.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Birgit
Top achievements
Rank 1
answered on 13 Jun 2017, 02:09 PM

Hello Dilyan

your're right, it's my mistake. I've found only the TotalItemCount and ItemCount property. But there is another property count, this works perfect for filtered and grouped Items.

Many Thanks

Tags
GridView
Asked by
Birgit
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Birgit
Top achievements
Rank 1
Share this question
or