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

Customising Pager

6 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shailendra
Top achievements
Rank 1
Shailendra asked on 01 Jul 2008, 10:11 PM
Hi,

I have a radgrid that uses paging to display fixed no. of records in each page. I let my users select no. of items they want to see in each page. Now, when the total number of records are less than the number_of_items_to_display, I still want to display this text "Displaying page 1 of 1, items 1 to 8 of 8." but not the "Change Page <1>" text. I have set the PagerStyle.AlwaysVisible property to True.

<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />

In one sentence, I want:

"Displaying page 1 of 1, items 1 to 8 of 8. "

instead of

"Change page:  <1>   Displaying page 1 of 1, items 1 to 8 of 8. "

One more small question. I am sorting my data before displaying it. But radgrid doesnt display the sort-direction icon on top of the column until someone sorts it again. How can I set it when I display it initially?

Thanks.
~SP

6 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 02 Jul 2008, 12:00 PM
Hi Shailendra,

Please consult the following help article, which shows how to customize the RadGrid pager at runtime:

http://www.telerik.com/help/aspnet-ajax/grdprogrammaticpagercustomization.html


Regards,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Shailendra
Top achievements
Rank 1
answered on 02 Jul 2008, 06:17 PM
Thanks Dimo. That helped.

I have another question too.

I am sorting my data before displaying it. But radgrid doesnt display the sort-direction icon on top of the column until someone sorts it again. How can I set it when I display it initially?

Thanks,
~SP
0
Dimo
Telerik team
answered on 03 Jul 2008, 07:40 AM
Hi Shailendra,

If you are sorting the data by yourself before displaying it initially, you can make the sort indicator appear by using:

ASPX

<telerik:RadGrid 
    ID="RadGrid1" 
    AllowSorting="true" 
    OnSortCommand="RadGrid1_SortCommand"
    <MasterTableView AllowCustomSorting="true"
        <SortExpressions> 
            <telerik:GridSortExpression FieldName="..." SortOrder="Ascending" /> 
        </SortExpressions> 
    </MasterTableView> 
</telerik:RadGrid> 

In this case RadGrid will not sort the already sorted data and the indicator will appear. The only thing to do more is to set AllowCustomSorting="False" on sort command, so that RadGrid starts sorting again:


C#

protected void RadGrid1_SortCommand(object sender, GridSortCommandEventArgs e) 
{  
    RadGrid1.MasterTableView.AllowCustomSorting = false




Sincerely yours,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Shailendra
Top achievements
Rank 1
answered on 03 Jul 2008, 08:02 PM
That did work but the sort icon disappears when the same column is sorted for the third time.

ASP code:

<telerik:RadGrid ID="rgAlgorithm" runat="server" AutoGenerateColumns="False"  
        EnableEmbeddedSkins="False" GridLines="None" Skin="GreenSkin"  
        AllowSorting="True" AllowPaging="True"  AllowCustomPaging="True"  
        Width="98%" OnSortCommand="rgAlgorithm_SortCommand" > 
         
        <MasterTableView AllowCustomSorting="true"
            <SortExpressions>  
                <telerik:GridSortExpression FieldName="ScoringAlgorithmName" SortOrder="Ascending" />  
            </SortExpressions>  

Code behind:

Protected Sub rgAlgorithm_SortCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridSortCommandEventArgs) Handles rgAlgorithm.SortCommand 
        rgAlgorithm.MasterTableView.AllowCustomSorting = False 
    End Sub 

I am not sure if I am making any mistake. I am using LLBLGen to fetch data from the database and using its sort expression.

Thanks.
~SP
0
Accepted
Dimo
Telerik team
answered on 04 Jul 2008, 09:07 AM
Hi Shailendra,

This is expected behavior - when you click on the sort arrow (or header text), the sorting modes change like this:

Ascending -> Descending -> None -> Ascending .....

When the sorting mode is "None", the sort arrow disappears.

If you want to switch between Ascending and Descending only, you should set the AllowNaturalSort property to False, as described here:

RadGrid - Controlling sorting modes


Regards,
Dimo
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Shailendra
Top achievements
Rank 1
answered on 08 Jul 2008, 08:00 PM
Thanks a lot Dimo!
Tags
Grid
Asked by
Shailendra
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Shailendra
Top achievements
Rank 1
Share this question
or