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

prevent hiding all columns in RadGrid?

2 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sean
Top achievements
Rank 1
sean asked on 01 Dec 2010, 05:59 PM


Hi,
I'm using the RadGrid and the "AllowColumnHide" feature.  Is there a way to specify that a column is excluded from the hide-column list that appears when right-clicking on the header?  

The problem is that a user could unselect every column.  This would be a disaster if this was paired with saving grid attributes.

see these Telerik demos for an example:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/savinggridsettingsonperuserbasis/defaultcs.aspx

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/headercontextfiltermenu/defaultcs.aspx

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 03 Dec 2010, 09:36 AM
Hi Sean,

The easiest thing to do in your case is to prevent the last visible column from being hidden:

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

function checkForLast(sender, args)
{
    var cols = sender.get_masterTableView().get_columns();
    var columnVisibilityFlag = 0;
    for (var j = 0; j < cols.length; j++)
    {
        if (cols[j].get_visible())
            columnVisibilityFlag++;
    }
    if (columnVisibilityFlag < 2)
        args.set_cancel(true);
}


Kind regards,
Dimo
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
sean
Top achievements
Rank 1
answered on 03 Dec 2010, 03:58 PM

thanks for the response.  I'd like the menu choice to go away, rather than cancelling the user's selection.  
I think I can do it in the PreRenderComplete event, described in here:
http://www.telerik.com/help/aspnet-ajax/grid-header-context-menu.html

this post also has some info about doing something similar:
http://www.telerik.com/community/forums/aspnet-ajax/grid/remove-options-from-radgrid-header-context-menu.aspx


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