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

Jump to specific column

1 Answer 63 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Tommy asked on 14 Oct 2010, 12:42 PM

I have a Grid with more than 100 columns. Is is possible to jump to a specific column in this Grid?

Thanks for your help

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 14 Oct 2010, 03:48 PM
Hello Tommy,

If you mean "jump" server side, then you can use the GetColumn and GetColumnSafe methods of the RadGrid tableviews.

If you mean to scroll horizontally to a specific column, then you can achieve this manually like this:

<%@ 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 = 40;
        int rowsNum = 6;
        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);
        (sender as RadGrid).DataSource = dt;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
    <ItemStyle Wrap="false" />
    <AlternatingItemStyle Wrap="false" />
        <Scrolling AllowScroll="true" UseStaticHeaders="true" ScrollHeight="" />
<script type="text/javascript">
function scrollToColumn()
    var grid = $find("<%= RadGrid1.ClientID %>");
    var colOffset = grid.get_masterTableView().getColumnByUniqueName("Column20").get_element().offsetLeft;
    grid.get_masterTableView().get_element().parentNode.scrollLeft = colOffset;

Sincerely yours,
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
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question