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

Hiding numeric paging hyperlinks in Grid

2 Answers 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 27 Jul 2010, 03:15 PM
Hi support,

I was wondering if it's possible to programmatically hide (on the server-side) the links the pager creates by default in the grid.

Could you give me an example of how I would do this and in what event?

Thanks,
Josh

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 30 Jul 2010, 12:18 PM
Hi Josh,

Generally, you can (and should) use the ItemCreated event. Assuming that you are using the NextPrevAndNumeric pager mode, the code should read:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridPagerItem)
    {
        GridPagerItem item = e.Item as GridPagerItem;
        (item.PagerContentCell.Controls[0].Controls[0].Controls[0].Controls[1] as Panel).Visible = false;
    }
}


Alternatively, you can do the same client-side with CSS:


<%@ 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 = 4;
        int rowsNum = 50;
        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;
    }
     
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
<style type="text/css">
 
div.RadGrid_Default .rgPager .rgNumPart
{
    display:none;
}
 
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadGrid
    ID="RadGrid1"
    runat="server"
    AllowPaging="true"
    OnNeedDataSource="RadGrid_NeedDataSource">
</telerik:RadGrid>
 
</form>
</body>
</html>



Greetings,
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
0
Josh
Top achievements
Rank 1
answered on 30 Jul 2010, 01:50 PM
Dimo,

I implemented your C# code.  It works great.

Thanks.

Josh

Tags
Grid
Asked by
Josh
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Josh
Top achievements
Rank 1
Share this question
or