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

Paging message incorrect

1 Answer 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jidesh Guptha
Top achievements
Rank 1
Jidesh Guptha asked on 15 Jun 2010, 03:02 PM
Hi,

In the grid i have set the page styele mode as "NextPrevAndNumeric" if i filter and the result has more than one row (say 15 Rows) displayed then the message displays as "15 items of 2 Pages" is getting displayed. if the No. of row is one then it is displaying as "1 items of 1 Page " is getting displayed which needs to be changed as "1 item of 1 Page".

How do i fix this pls Help me to fix.

Jidesh

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 15 Jun 2010, 04:16 PM
Hello Jidesh,

You can modify the pager content in PreRender, depending on the number of data rows:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server">
 
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable dt = new DataTable();
        DataRow dr;
        int colsNum = 3;
        int rowsNum = 10;
        string colName = "Column";
 
        for (int j = 1; j <= colsNum; j++)
        {
            dt.Columns.Add(String.Format("{0}{1}", colName, j));
        }
 
        for (int i = 1; i <= rowsNum; i++)
        {
            dr = dt.NewRow();
 
            for (int k = 1; k <= colsNum; k++)
            {
                dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i);
            }
            dt.Rows.Add(dr);
        }
 
        (sender as RadGrid).DataSource = dt;
    }
 
    protected void RadGrid_PreRender(object sender, EventArgs e)
    {
        if ((sender as RadGrid).MasterTableView.Items.Count == 1)
        {
            GridItem[] items = (sender as RadGrid).MasterTableView.GetItems(GridItemType.Pager);
            foreach (GridItem item in items)
            {
                LiteralControl infoPart = (item as GridPagerItem).PagerContentCell.Controls[0].Controls[0].Controls[0].Controls[4].Controls[0] as LiteralControl;
                infoPart.Text = infoPart.Text.Replace("items", "item");
                infoPart.Text = infoPart.Text.Replace("pages", "page");
            }
        }
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head id="Head1" runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    Width="600px"
    AllowFilteringByColumn="true"
    AllowPaging="true"
    OnNeedDataSource="RadGrid_NeedDataSource" OnPreRender="RadGrid_PreRender">
    <PagerStyle AlwaysVisible="true" />
</telerik:RadGrid>
 
</form>
</body>
</html>


Regards,
Dimo
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Jidesh Guptha
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or