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

[Solved] Grids - Freezing Columns

3 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Adam Sime
Top achievements
Rank 1
Adam Sime asked on 28 Jan 2010, 03:20 PM
Hi,

Is it possible to freeze columns in your grids? I would like to be able to scroll horizontally through data and have the first 2 columns in my grid constantly visible. Is this possible? If so, how? I'm using MVC grids, by the way.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 28 Jan 2010, 04:16 PM
Hello Adam Sime,

No, the MVC grid does not support frozen columns. It is however possible to use RadGrid for ASP.NET Ajax inside an MVC application. The latter supports frozen columns.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Vanessa
Top achievements
Rank 1
answered on 28 Apr 2011, 06:00 AM
Hi,

I have implemented freeze columns for RadGrid MVC. Please check out the link

http://www.codeproject.com/KB/scripting/freezeColumn_RadGrid_MVC.aspx
0
Irabanta
Top achievements
Rank 1
answered on 18 Apr 2012, 07:34 AM
I am writing a reply to this post to let you all know that Column Freezing can be easily applied to Telerik's MVC grid. I have worked out with many alternatives provided in various forumns and end up with poor performance and my client is not accepting the solution. This one is a simple and light appoach i have concluded.
The solution will need a css class and a javascript function. you will need to call the js function on client side event "OnDataBound".
the following gives you 50% solution. you will need to bind client event of the grid for OnEdit, OnRowDataBound.... and implement the similar code as i do in contentDiv.scroll event handler.
-----tested on IE, FF, Chrome, Safari------------------
td.locked, th.locked { z-index:99; position:relative; /* any attributes you need */}
//for firefox, use position:absolute. but this will give an unpleasent background;

function freezeColumn(telerikGridId){
    //use jquery
    var grid = $('#' + telerikGridId);
    var gridRows = grid.find('tr');
    gridRows.each(function(){
        var firstTd = $(this).find('td')[0];
        $(firstTd).addClass('locked');
    });
    //very important solution
    var contentDiv = grid.find('.t-content-grid'); //USE IE DEVELOPER TOOL to find the exact class name
    contentDiv.scroll(function(){
        var leftPosition = contentDiv.scrollLeft();
        gridRows = grid.find('tr');
        gridRows.each(function(){
            var firstTd = $(this).find('td')[0];
            $(firstTd).css('left', leftPosition);
        });
    });
}
Tags
Grid
Asked by
Adam Sime
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Vanessa
Top achievements
Rank 1
Irabanta
Top achievements
Rank 1
Share this question
or