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

Disable column header in rad grid

2 Answers 204 Views
Grid
This is a migrated thread and some comments may be shown as answers.
waruni
Top achievements
Rank 1
waruni asked on 07 Jan 2011, 11:08 AM

Hi,

I have a grid and  i used the sorting functionality. so if no records in grid and when i clicked on sorting it will fill the data to the grid.
Is there any way to disable sorting for a column header when there are no record in the grid. 

thanks
waruni

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 07 Jan 2011, 12:09 PM
Hello Waruni,

A possible approach is to set the AllowSorting property in the NeedDataSource handler:
protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    if (items_in_my_datasource.Count == 0)
        RadGrid1.AllowSorting = false;
    else
        RadGrid1.AllowSorting = true;
 
    (source as RadGrid).DataSource = my_data;
}

It is also possible to count the items in RadGrid after it has been bound but this will require that you rebind the control manually in normal circumstances.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start 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
waruni
Top achievements
Rank 1
answered on 09 Jan 2011, 07:09 AM
Hi,

Thanks for the quick reply, its work :)

waruni
Tags
Grid
Asked by
waruni
Top achievements
Rank 1
Answers by
Daniel
Telerik team
waruni
Top achievements
Rank 1
Share this question
or