Customizing slider in RadGrid

7 posts, 0 answers
  1. Warnestam
    Warnestam avatar
    83 posts
    Member since:
    Sep 2006

    Posted 07 Jul 2008 Link to this post

    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?
  2. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 08 Jul 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Warnestam
    Warnestam avatar
    83 posts
    Member since:
    Sep 2006

    Posted 08 Jul 2008 Link to this post

    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?
  5. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 10 Jul 2008 Link to this post

    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
  6. Warnestam
    Warnestam avatar
    83 posts
    Member since:
    Sep 2006

    Posted 10 Jul 2008 Link to this post

    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?

  7. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 11 Jul 2008 Link to this post

    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
  8. Warnestam
    Warnestam avatar
    83 posts
    Member since:
    Sep 2006

    Posted 13 Jul 2008 Link to this post

    Thanks, even if the code is very sensitive to changes in the Telerik code the outpuit is just what I like.

    Regards

    Robert
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017