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

Customizing slider in RadGrid

6 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Warnestam
Top achievements
Rank 1
Warnestam asked on 07 Jul 2008, 09:41 PM
Hi,

I'm looking for a way to customize the pager in RadGrid. I've set the Pager-Mode style to Slider and would at least localize the text belonging to it.
Catching the ItemCreate event I've managed to get the RadSlider component (and used that to set some of text). Is it possible to lozalize the "Page: x out of y pages" text also?

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 08 Jul 2008, 07:42 AM
Hi Robert,

This is the code needed to achieve the desired scenario:
<ClientSettings> 
    <ClientMessages PagerTooltipFormatString="The current page is: {0} of {1}" /> 
</ClientSettings> 
 

Sincerely yours,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Warnestam
Top achievements
Rank 1
answered on 08 Jul 2008, 08:23 AM
Thanks Daniel!

Now I can show the page, but  I would also like to show the number of records found. In the PagerTextFormat property there is several more fields that can be formatted, and PagerTooltipFormat only has two. Is there a reason for this? Another thing that I really would like to do, is to style the slider (adjusting the position of the text). Can this be doe?
0
Daniel
Telerik team
answered on 10 Jul 2008, 01:41 PM
Hi Robert,

PagerTextFormat is concerning NextPrev and NextPrevAndNumeric modes as you can see in this article: Using PagerTextFormat. At the other hand PagerTooltipFormat is used when you have a Slider as a pager.
You can try to add some text to the label showing PagerTooltipFormatString but you should keep in mind that when you refresh the page (postback) your text may disappear for a second. Here is a possible approach:

protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    GridPagerItem gpi = e.Item as GridPagerItem; 
    if (gpi != null
    { 
        TableCell tc = gpi.PagerContentCell; 
        Label label = tc.FindControl("RadGrid1_SliderPagerLabel"as Label; 
        if (label != null
        { 
            label.Text += ", Total records: " + gpi.Paging.DataSourceCount; 
        } 
    } 

Regarding the second question: you can use RadGrid1.PagerStyle.Position to adjust the position of the Pager text.

Greetings,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Warnestam
Top achievements
Rank 1
answered on 10 Jul 2008, 10:28 PM
Q1

I just think that PagerTooltipFormat could have the same possibilities as PagerTextFormat. Catching the ItemCreate event should fix it, but the name of the label can be hard to find. In my case I found that the labels id was "ctl00_ContentPlaceHolder1_rgEvents_SliderPagerLabel". It has the same naming container as the RadSlider component, which I can find by the following statement;


e.Item.FindControl("GridSliderPager") as RadSlider;

But you line, did not work;

Label label = tc.FindControl("rgEvents_SliderPagerLabel"as Label; 

Any suggestions?

Q2

Yes with the Position property you can place the pager at the top or the bottom. But I was interesting in styling the pager by moving only the text part to the right. It look likes you have hardcoded the appearance of the slider, is that correct or is there a way for me to alter the position of the text?

0
Daniel
Telerik team
answered on 11 Jul 2008, 03:33 PM
Hello Robert,

To change the label position you could use the following:
tr.GridPager_Default .sliderPagerLabel_Default 
    float: right; 

To change the slider position:
.GridPager_Default .radslider 
    float: right; 

Also you can find a sample project attached to this thread.

Greetings,
Daniel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Warnestam
Top achievements
Rank 1
answered on 13 Jul 2008, 11:16 AM
Thanks, even if the code is very sensitive to changes in the Telerik code the outpuit is just what I like.

Regards

Robert
Tags
Grid
Asked by
Warnestam
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Warnestam
Top achievements
Rank 1
Share this question
or