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

Dynamic Page Size Issue

0 Answers 112 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Azharshah
Top achievements
Rank 1
Azharshah asked on 31 May 2018, 12:33 PM

Hi Telerik,

I’m using RadGridView and RadDataPager. Items bound to RadDataPager Source. RadGridView’s ItemsSource is the PagedSource of RadDataPager. I’m using dynamic page size concept. For this I have styled the DataPagerPresenter. The RadComboBox is used inside the style for selecting the Page Size. A converter is used to set the ItemsSource of the RadComboBox.

The problem I’m facing here is, while initializing the RadDataPager the converter gets fired and the initial Page size (10) is set as ItemsSource. After the items are fetched from the service, The items are set to Source of the RadDataPager. Now, the converter is not getting fired to update the page size itemssource as it is having 1000 records. I want to display 10, 20, 30, 40, 50 as ItemsSource of RadComboBox.

How to update the ItemsSource of RadComboBox when items are set?

 

<ControlTemplate x:Key="DataPagerPresenterTemplate" TargetType="dataPager:DataPagerPresenter">
...
...
...
<tk:RadComboBox x:Name="pageSizeOptionComboBox" Grid.Column="1"
                        ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource pageSizeCountConverter}}"
                        SelectedValue="{Binding PageSize, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
...
...
...
</ControlTemplate>

 

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DataPagerPresenter presenter = value as DataPagerPresenter;
            var totalCount = presenter.PageCount * presenter.PageSize;
            int i = 1;
            List<int> result = new List<int>();
            for (int j = 0; j < totalCount && result.Count < 5; j++)
            {
                if (i % 10 == 0)
                {
                    result.Add(i);
                }

                i++;
            }

            return result;
        }

 

No answers yet. Maybe you can help?

Tags
DataPager
Asked by
Azharshah
Top achievements
Rank 1
Share this question
or