I'm working with RadDataPager and RadGridView. All works fine.
I would like to customize the RadDataPager and add a DropDown with some fixed page sizes.
So the user can choice if he wants to show 10, 20, 50 or 100 items in the page.
Is it possibile to do this? Do you have an example?
Thanks.
Alessandro
7 Answers, 1 is accepted
You will need to edit the control template of the pager, place your custom control somewhere inside the DataPagerPresenter, and Bind its Value property to the PageSize. You will need the Latest Internal Build version in order to do this.
I hope this helps.
Greetings,
Ross
the Telerik team
Thanks
We don't have plans to add such a feature, since we don't consider this to be a feature at all. We can do it for around 5 minutes, but we don't think that it is right. Let me try to explain why.
In the XAML plartorms WPF and Silverlight, there are two extremely powerful features called Control Templates and Data Binding. With the help of these two features, you can alter the appearance and functionality of any control in an infinite number of ways.
For example, you can add a combo-box in RadDataPager's template and bind its SelectedValue to the PageSize property of the control. Or you can add a TextBox. Or a RadNumericUpDown. Or a RadSlider that will change the PageSize when the user slides left and right. In fact, you can add any kind of control and bind it to the PageSize property. Why limit your choice to a combo? You personally want a combo, but another customer can place a slider, since he likes sliders better. Which one should we add out-of-the-box as a feature? The answer is none. It is not that we cannot. It's around 5 lines of XAML and is pretty easy. It is because, we can't decide what is best for everyone.
If we decide to add a combo that you will show up when you turn on a single boolean property, what page sizes should it offer? "5, 10, 20, 100" or "10, 50, 150"? Should it be on the left side or on the right side? Should it be pink, yellow or brown? How many items should it have? Why not a RadSlider instead of the combo? I believe that you see where I am getting at.
Since everyone out there will have a specific personal requirement -- he or she can easily achieve it with a few lines of XAML. That's the whole beauty of the Silverlight platform.
We have exposed the PageSize property and everyone out there can bind it to anything that he wants. Thus everyone is happy. It's not that we can't add such a feature, in fact we have already created such a project in the code library that my colleague mentioned, we simply don't believe that this is the right thing to do just for the reasons I have explained above. You are watching from your tower and you want a combo, but other people may want a, let's say RadNumericUpDown, which is on the left size of the pager and is green. We can't add a separate "feature" for every one. That's why XAML, Visual Studio and Expression Blend exist -- there is the PageSize property -- go ahead and define the UI that will bind to it.
I really hope that I was able to explain all of these. Let me know if I could not.
Ross
the Telerik team
I forgot the link to the code-library:
http://www.telerik.com/community/code-library/silverlight/datapager/dynamically-change-the-pagesize-of-raddatapager.aspx
I hope this helps.
Ross
the Telerik team
What would be the best approach if I wanted to put this into a resource dictionary so I could use this style across multiple data pagers?
What I'm looking for is to somehow know what the drop down selected and to know the source binding of that data pager since 99% of the time I'd be using this in a DomainDataSource scenario and the page size would be set there, not on the pager.
http://www.telerik.com/help/aspnet-ajax/datapager-elements.html
Also, there's a difference in choosing to please no one versus choosing to please the most likely (or most asked for) capability, along with still providing means to other people to get what they want using methods they would have had to use anyway.
Just wondering...
Thanks.
(Regardless, that was a good, detailed answer you gave, so thank you.)
Dempsey
Thanks ~Doug