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

Filtering, AutoGenerateColumns and DataSets

2 Answers 195 Views
Grid
This is a migrated thread and some comments may be shown as answers.
KobusVisagie
Top achievements
Rank 1
KobusVisagie asked on 20 Sep 2010, 10:37 AM
Hello Telerik,

I have the following RadGrid on my page:

<telerik:RadGrid ID="rgVehicles" runat="server"
    AutoGenerateColumns="True"
    AllowFilteringByColumn="True" AllowPaging="True"
    AllowSorting="True">
    <PagerStyle Mode="NextPrevAndNumeric" />
    <GroupingSettings CaseSensitive="false" />
</telerik:RadGrid>

I then assign a DataTable to the RadGrid's DataSource property (on Page_Load):

rgVehicles.DataSource = dsVehicles.Tables[0];
rgVehicles.DataBind();

Filtering is completely disabled when I run the website and view this RadGrid. Your documentation states:

The built-in filtering feature is not supported when you bind the grid by explicitly calling DataBind().

My question is, how do I enable filtering then? Bare in mind AutoGenerateColumns is set to True, meaning when I call a Stored Procedure and populate a DataSet, I won't always know what the columns will be.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Sep 2010, 11:23 AM
Hello Gregory,

Bind your grid using advanced Data-binding(Using NeedDataSource event).

Please refer the following documentation
Advanced Data-binding (using NeedDataSource event).

C#:
protected void rgVehicles_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        rgVehicles.DataSource = dsVehicles.Tables[0];
    }

Thanks,
Princy.
0
KobusVisagie
Top achievements
Rank 1
answered on 20 Sep 2010, 11:46 AM
Thank you, that solved the problem. Now it seems that something in the websites design is interfering with the Filter buttons being clickable. Is there something that could cause this off the top of your head?

EDIT: It was an issue with some DIV tags in the site, the z-index played a role here. Please ignore the above. Thanks again for your help.
Tags
Grid
Asked by
KobusVisagie
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
KobusVisagie
Top achievements
Rank 1
Share this question
or