Telerik Forums
UI for WPF Forum
1 answer
71 views

Hello,

 

Here is my situation:

1. I have got client app in WPF ( Cant create here any db context etc )

2. I have got Rest Api where is DbContext (EntityFramework)

3. I have got RadGrid and RadPager

 

I want to pass QueryableCollectionView or QueryableEntityCollectionView or something else? to this rest api, processing data, use filters, pagination and sorters from radgrid. Then in returns i want to receive collection of Products, Employees or something

 

Is any body do something like this? I know that in Blazor UI there is DataSourceRequest etc and it works fine, but i did not find alternative in WPF

Martin Ivanov
Telerik team
 answered on 18 May 2023
1 answer
115 views

Hello.

 

I have the same situation as https://www.telerik.com/forums/virtual-page-count.
Since the database has over 100 million data, I don't want to bring all the data into memory.
When a user clicks on a specific page, I'm trying to get only the data in that range from the DBMS.


I also read about Unbound Mode (https://docs.telerik.com/devtools/wpf/controls/raddatapager/features/unbound-mode)
But this seems to use code-behind.
I don't want to write a code-behind because I use the MVVM pattern.
How can I do it?

 

The code below has been simplified.

 

1. DataView.xaml

<UserControl x:Class="MyProject.Views.MyDataView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MyProject.Views"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
             mc:Ignorable="d" 
             d:DesignHeight="550" d:DesignWidth="1920">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="26" />
            <RowDefinition Height="400"/>
            <RowDefinition Height="28" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" HorizontalAlignment="Right">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Page Size" Margin="2 8 12 2"  FontWeight="SemiBold"/>

                <telerik:RadComboBox 
                                 Height="22"
                                 Margin="0 0 10 0"
                                 FontFamily="Segoe UI"
                                 ClearSelectionButtonVisibility="Visible" 
                                 ClearSelectionButtonContent="Show all" 
                                 DisplayMemberPath="DisplaySize" 
                                 ItemsSource="{Binding MyDataPageSize}" 
                                 SelectedItem="{Binding SelectedMyDataPageSize}"
                                 AllowMultipleSelection="False"
                                 Command="{Binding RefreshMyDataCommand}"/>
            </StackPanel>
        </Grid>

        <telerik:RadGridView x:Name="MyDataGridView"
                             Grid.Row="1"
                             IsFilteringAllowed="False"
                             AutoGenerateColumns="False"
                             ShowGroupPanel="False"
                             CanUserFreezeColumns="False"
                             RowIndicatorVisibility="Collapsed"
                             SelectionMode="Extended"
                             TextBlock.TextAlignment="Center"
                             CanUserSortColumns="False"
                             IsReadOnly="True"
                             Margin="10 5 10 0"
                             ScrollMode="RealTime"
                             ItemsSource="{Binding DynamicGridViewItemSource}"
        </telerik:RadGridView>

        <telerik:RadDataPager Grid.Row="2"
				x:Name="MyDataPager"
                              Width="{Binding ElementName=MyDataGridView, Path=ActualWidth}"
							  PageSize="{Binding SelectedMyDataPageSize.Size}"
							  Source="{Binding Items, ElementName=MyDataGridView}"
							  ItemCount="{Binding TotalItemCount}"
                              BorderThickness="1,0,1,1"
							  DisplayMode="All"
                              AutoEllipsisMode="Both"
							  NumericButtonCount="10"
							  IsTotalItemCountFixed="False" >
            <behaviors:Interaction.Triggers>
                <behaviors:EventTrigger EventName="PageIndexChanged">
                    <behaviors:InvokeCommandAction Command="{Binding PageIndexChangedCommand}"
                                           CommandParameter="{Binding ElementName=MyDataPager, Path=PageIndex}" />

                </behaviors:EventTrigger>
            </behaviors:Interaction.Triggers>
        </telerik:RadDataPager>
    </Grid>
</UserControl>

 

2. DataViewModel.cs

namespace MyProject.ViewModels
{
    public class StageDTO
    {
        public string StartNumber { get; set; }
        public string EndNumber { get; set; }
    }

    public class MyDataViewModel : ViewModelBase
    {

// some code

        private int _totalItemCount;
        public int TotalItemCount
        {
            get
            {
                return _totalItemCount;
            }
            set
            {
                _totalItemCount = value;
                OnPropertyChanged(nameof(TotalItemCount));
            }
        }

        public MyDataViewModel(CyclerMode mode)
        {
            // do something
        }

        public void ShowMyDataOfSelectedStage(object parameter)
        {
           StageDTO dto = parameter as StageDTO;
 
            // do something

          // and i calculate TotalItemCount here
                TotalItemCount = Convert.ToInt32(dto.EndNumber) - Convert.ToInt32(dto.StartNumber);
           
        }
    }
}

 

There may have been a typo in the process of simplifying, but there is no problem when i actually run the program.

TotalItemCount = Convert.ToInt32(dto.EndNumber) - Convert.ToInt32(dto.StartNumber);

The data goes in correctly in the code above, but nothing changes.

I made the changes below, but it still doesn't work.

ItemCount="{Binding TotalItemCount, UpdateSourceTrigger=PropertyChanged}"

If I change it like below
ItemCount="{Binding TotalItemCount, Mode=TwoWay}"

I am getting an exception like below.
System.InvalidOperationException: 'Setting RadDataPager.ItemCount is allowed in Unbound Mode only.'

 

How do I get it to work like I want?

Vladimir Stoyanov
Telerik team
 answered on 10 May 2023
1 answer
251 views

How I can do server-side paging/sorting/filtering in a RadDataGrid. I retrieve the data from an azure function and I don't want to retrieve all data from the database. I pass as a parameter to the azure function, the page index, and the page size.  the response returns the result of the LINQ query with Skip(page index) and Take(page Size), and total row count.

Thank you for your help.

Martin Ivanov
Telerik team
 answered on 07 Feb 2022
2 answers
68 views

     Hi,

I've added a DataPager to a DataGrid, and now the DataGrid.IsSynchronizedWithCurrentItem property is not working.  How can I resolve this?  Below is my code...

<DockPanel LastChildFill="True">
    <telerik:RadDataPager x:Name="radDataPager"
    DockPanel.Dock="Bottom"
                          Source="{Binding GridData}"
                          PageSize="100"
                          DisplayMode="All"
                          AutoEllipsisMode="After"
                          NumericButtonCount="5"/>
    <telerik:RadGridView x:Name="radGridView"
                         Margin="0"
                         Width="{Binding ElementName=GridViewGrid, Path=ActualWidth}"
                         EnableColumnVirtualization="True"
                         EnableRowVirtualization="True"
                         AlternateRowBackground="AliceBlue"
                         ItemsSource="{Binding PagedSource, ElementName=radDataPager}"
                         SelectionUnit="FullRow"
                         RowIndicatorVisibility="Collapsed"
                         GridLinesVisibility="None"
                         ScrollMode="Deferred"
                         FilteringMode="Popup"
                         CanUserFreezeColumns="False"
                         AutoGenerateColumns="True"
                         ColumnWidth="Auto"
                         IsSynchronizedWithCurrentItem="True"
                         IsReadOnly="True"
                         IsTabStop="False"
                         ValidatesOnDataErrors="InEditMode"
                         amUI:GridViewEventManager.IsEnabled="True"
                         amUI:LookupTextBoxFilterBehavior.LookupTextBox="{Binding ElementName=LookupTextBox}">
    </telerik:RadGridView>
</DockPanel>

 

Vladimir Stoyanov
Telerik team
 answered on 14 Jan 2021
1 answer
54 views

I am trying to use DataPager on my grid. My goal is to put the pager on the different part of my screen.

For example, I have a window with two main grid. I used a Frame on the first grid to display a page with RadGridView. This Grid is the one I want to have the Pager. But I want to put the Pager on the second Grid of my main window. This is for layout purpose. Is this possible? 

 

Thank you

Martin Ivanov
Telerik team
 answered on 21 Jul 2020
2 answers
128 views

I have an existing WPF application which uses Microsoft.Windows.controls.Datagrid. I want to add the RadDataPager to do the pagination, how can I do it? 

Here's my sample code. It displays the data but it doesn't do the pagination. All data is displayed in a single page.

<dg:DataGrid Name="dgRegistryDetails" FontSize="14" DockPanel.Dock="Bottom" Foreground="#FF07315B"

                         ItemsSource="{Binding}"   CanUserSortColumns="true"
IsReadOnly="True"    AutoGenerateColumns="False" >

 

<telerik:RadDataPager VerticalAlignment="Bottom" DisplayMode="FirstLastPreviousNextNumeric" Source="{Binding Items, ElementName=dgRegistryDetails}"  IsTotalItemCountFixed="True" x:Name="RadPager" PageSize="10" />

Niraja
Top achievements
Rank 1
 answered on 08 Nov 2019
0 answers
47 views

I have the TabControl with any TabPages. Each page has TreeView with with several thousand nodes + DataPager. All TabPages have identical XAML and ViewModel. An exception occurs when I switch between pages (incorrect arguments RadDataPager.PageSize and RadDataPager.PageIndex). If  TreeView on selecting TabPage is empty exeption not occurs.

Fragment my XAML :

...

<telerik:RadDataPager x:Name="xDataPager" Grid.Column="2" Margin="10,0,10,0"
PageSize="{Binding Value, ElementName=ndCount,Mode=TwoWay,UpdateSourceTrigger=Explicit}" FontSize="12"
BorderThickness="1,0,1,1" DisplayMode="All"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
Source="{Binding ObjectList,Mode=TwoWay,NotifyOnSourceUpdated=True,UpdateSourceTrigger=PropertyChanged}"
PageIndex="{Binding ActualPage, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
IsTotalItemCountFixed="false" >
<telerik:EventToCommandBehavior.EventBindings>
<telerik:EventBinding Command="{Binding PageChangedCommand}" EventName="PageIndexChanged" RaiseOnHandledEvents="False" PassEventArgsToCommand="True" />
<telerik:EventBinding Command="{Binding PageChangingCommand}" EventName="PageIndexChanging" RaiseOnHandledEvents="False" PassEventArgsToCommand="True" />
</telerik:EventToCommandBehavior.EventBindings>
</telerik:RadDataPager>
<StackPanel Orientation="Horizontal" Grid.Column="3" VerticalAlignment="Center" Margin="10,0,10,0">
<TextBlock Text="Объектов на странице :" FontSize="12" VerticalAlignment="Center" />
<telerik:RadNumericUpDown x:Name="ndCount" IsInteger="True" ValueFormat="Numeric" Value="{Binding PageSize, Mode=TwoWay,UpdateSourceTrigger=Explicit,NotifyOnValidationError=True}" Minimum="10" Maximum="200" SmallChange="5" LargeChange="10" VerticalAlignment="Center" Margin="5,0,10,0"/>
</StackPanel> <telerik:RadDataPager x:Name="xDataPager" Grid.Column="2" Margin="10,0,10,0"
PageSize="{Binding Value, ElementName=ndCount,Mode=TwoWay,UpdateSourceTrigger=Explicit}" FontSize="12"
BorderThickness="1,0,1,1" DisplayMode="All"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
Source="{Binding ObjectList,Mode=TwoWay,NotifyOnSourceUpdated=True,UpdateSourceTrigger=PropertyChanged}"
PageIndex="{Binding ActualPage, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
IsTotalItemCountFixed="false" >
<telerik:EventToCommandBehavior.EventBindings>
<telerik:EventBinding Command="{Binding PageChangedCommand}" EventName="PageIndexChanged" RaiseOnHandledEvents="False" PassEventArgsToCommand="True" />
<telerik:EventBinding Command="{Binding PageChangingCommand}" EventName="PageIndexChanging" RaiseOnHandledEvents="False" PassEventArgsToCommand="True" />
</telerik:EventToCommandBehavior.EventBindings>
</telerik:RadDataPager>
<StackPanel Orientation="Horizontal" Grid.Column="3" VerticalAlignment="Center" Margin="10,0,10,0">
<TextBlock Text="Objects on page:" FontSize="12" VerticalAlignment="Center" />
<telerik:RadNumericUpDown x:Name="ndCount" IsInteger="True" ValueFormat="Numeric" Value="{Binding PageSize, Mode=TwoWay,UpdateSourceTrigger=Explicit,NotifyOnValidationError=True}" Minimum="10" Maximum="200" SmallChange="5" LargeChange="10" VerticalAlignment="Center" Margin="5,0,10,0"/>
</StackPanel>

...

 

Rumyantsev
Top achievements
Rank 1
 asked on 21 Oct 2019
1 answer
200 views

Hi !

How do I get the total record count of the RadDataPager at any given time ?

The count on load, after a sort, after a filter...etc.

The end goal being (displayed under my RadDataGrid):

"Total Number of Records: 1536"

or even better, based on a PageSize=100 :

"Displaying 300-400 (of 1536 records)"

 

...I'm assuming you guys would have added this functionality a long time ago - maybe within the RadDataGrid itself, after the Paging is wired in ?!!?

Barry
Top achievements
Rank 1
 answered on 01 Aug 2019
1 answer
52 views

Hi,

I have paging enabled and it works great, however my sorting functionality is now dead. In fact, the sorting indicators are removed from the grid entirely.

Is it a choice between speed gains for large data-sets and functionality ?

Barry

Barry
Top achievements
Rank 1
 answered on 31 Jul 2019
1 answer
48 views

I just added a datapager to my project but it does not seem to be honoring the Windows8touch theme.

I have the window8touch dll referenced properly as everything else works.

==> Telerik.Windows.Themes.Windows8Touch

What do I have wrong.

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/System.Windows.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Chart.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Input.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Data.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.DataVisualization.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Navigation.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.Docking.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Documents.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Documents.Proofing.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8Touch;component/Themes/Telerik.Windows.Controls.GridView.xaml" />
</ResourceDictionary.MergedDictionaries>

 

David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
 answered on 17 Jun 2019
Narrow your results
Selected tags
Tags
+? more
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?