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

Filter Template Error

7 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Najid Hanif
Top achievements
Rank 2
Najid Hanif asked on 22 Aug 2011, 09:52 PM
I am trying to create my own custom filter like in the example outlined here:

http://www.telerik.com/help/aspnet-ajax/grid-custom-option-for-filtering.html

The only difference is that my column is a template column, What do i need to do? Thanks

Error on line: RadGrid1.MasterTableView.Rebind();
Telerik.Web.UI.ParseException was unhandled by user code
  Message=Expression expected
  Source=Telerik.Web.UI

ASPX
<telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn column"
    HeaderText="Status" UniqueName="Status">
 
<FilterTemplate>
  <telerik:RadComboBox runat="server" ID="FilterCombo" DataSourceID="StatusList"
                       DataValueField="StatusID" DataTextField="Status" AutoPostBack="true"
                       OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged">
  </telerik:RadComboBox>
</FilterTemplate>
 
    <EditItemTemplate>
        <telerik:RadComboBox ID="RadComboBox_StatusList" runat="server"
            AutoPostBack="true" DataSourceID="StatusList" DataTextField="Status"
            DataValueField="StatusID"
            OnSelectedIndexChanged="RadComboBox_StatusList_SelectedIndexChanged"
            SelectedValue='<%#Bind("StatusID") %>'>
        </telerik:RadComboBox>
    </EditItemTemplate>
    <ItemTemplate>
         <%#DataBinder.Eval(Container.DataItem, "Status")%>
    </ItemTemplate>
    <ItemStyle Width="240px" />
</telerik:GridTemplateColumn>


C#
protected void FilterCombo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
    string filterExpression;
    filterExpression = "([Status] = '" + e.Value + "')";
    RadGrid1.MasterTableView.FilterExpression = filterExpression;
    RadGrid1.MasterTableView.Rebind();
}



7 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 23 Aug 2011, 07:21 AM
Hello Najid Hanif,

Please try setting EnableLinqExpressions property of the RadGrid control to false and check whether this eliminates the exception.

Best wishes,
Pavlina
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Najid Hanif
Top achievements
Rank 2
answered on 23 Aug 2011, 01:55 PM
This does eliminate the exception but the filter does not do anything though. I select the item from the dropdown, and it reverts back to what was selected before and nothning is filtered.
0
Accepted
Princy
Top achievements
Rank 2
answered on 23 Aug 2011, 02:01 PM
Hello Najid,

Make sure that you have set DataField property for the GridTemplateColumn.

aspx:
<telerik:GridTemplateColumn DataField="StatusID" FilterControlAltText="Filter TemplateColumn column" 
    HeaderText="Status" UniqueName="Status">
  . . .
</telerik:GridTemplateColumn>

Thanks,
Princy.
0
Najid Hanif
Top achievements
Rank 2
answered on 23 Aug 2011, 02:13 PM
Thanks for the quick response, that did not change any behavior though.
0
Princy
Top achievements
Rank 2
answered on 24 Aug 2011, 08:22 AM
Hello Najid,

Make a double check your code with the following demo which implements the same.
Grid / Filter Templates.

Thanks,
Princy.
0
Najid Hanif
Top achievements
Rank 2
answered on 24 Aug 2011, 03:00 PM
That does not really help much as that is client side with java script.

I am trying to use this example, at the bottom:

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

Does that example not work?
Thanks
0
Najid Hanif
Top achievements
Rank 2
answered on 24 Aug 2011, 03:53 PM
I figured it out. The SQL Col needed to be changed to the ID col


 filterExpression = "([StatusID] = '" + e.Value + "')";
Tags
Grid
Asked by
Najid Hanif
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Najid Hanif
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or