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

custom filter in conjunction with standard built-in filter

5 Answers 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 10 Mar 2009, 06:51 PM
I have custom filtering implemented in my grid.
I have a dropdown inside the filtertemplatecolumn on one of the columns.

The rest of the columns have standard filtering.

If i have a value set in my dropdown and I try to set the filter value for another column both of them do not work simultaneously. I want the results filtered based on both the column filters, that is my custom filter and standard filter column.

My Grid columns are like this:

 

 

<

telerik:GridTemplateColumn HeaderText="Type" UniqueName="Type" HeaderStyle-Width="11%"

 

 

DataField="RelationType">

 

 

<FilterTemplate>

 

 

<telerik:RadComboBox ID="RadComboBoxRelatedContacts" runat="server" AutoPostBack="true"

 

 

Width="102px" OnSelectedIndexChanged="RadComboBoxRelatedContacts_SelectedIndexChanged">

 

 

<Items>

 

 

<telerik:RadComboBoxItem Text="Family" Value="Family" />

 

 

<telerik:RadComboBoxItem Text="Business" Value="Business" />

 

 

<telerik:RadComboBoxItem Text="Personal" Value="Personal" />

 

 

<telerik:RadComboBoxItem Text="Professional" Value="Professional" />

 

 

</Items>

 

 

</telerik:RadComboBox>

 

 

</FilterTemplate>

 

 

<ItemTemplate>

 

<%

# Eval("RelationType")%>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Employer/Title" UniqueName="Employer" HeaderStyle-Width="14%"

 

 

DataField="Employer" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true">

 

 

<ItemTemplate>

 

 

<b>

 

<%

# Eval("Employer")%></b>
</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 


.cs code

 

 

protected

void RadComboBoxRelatedContacts_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)

 

{

 

RadComboBox list = (RadComboBox)sender;

 

strRelTypeText = list.SelectedItem.Text;

 

string filterExpression = "([RelationType] = '" + list.SelectedValue + "')";

 

 

GridFilteringItem item = (GridFilteringItem)list.NamingContainer;

 

 

RadGrid gridKeyRel = (RadGrid)item.OwnerTableView.NamingContainer;

 

gridKeyRel.MasterTableView.FilterExpression = filterExpression;

gridKeyRel.MasterTableView.CurrentPageIndex = 0;

gridKeyRel.MasterTableView.Rebind();

}

can you help?

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 13 Mar 2009, 11:14 AM
Hello newbie,

Attached to this message, is a small application, which handles a similar task.
I hope it helps.

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
newbie
Top achievements
Rank 1
answered on 13 Mar 2009, 11:10 PM
that code did not work for me.
I am using the NeeddataSource event to bind the grid to the datasource.

I have an initial filter set on my custom filter column.
When i click on any one of the in-built filter columns then I lose the value of my custom filter.
If after that if I click on my filter drop down for my custom filter then the previous filter is applied and the new value filter value in the combo is not passed in the filterexpression.

Any ideas?
0
Yavor
Telerik team
answered on 16 Mar 2009, 01:03 PM
Hello,

The sample which I sent handles properly the filtering for both the column with the custom filter template, and any other column. If your setup is somewhat different, you can open a formal support ticket, and send us a small working project, demonstrating your setup, for additional testing.

Best wishes,
Yavor
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
newbie
Top achievements
Rank 1
answered on 16 Mar 2009, 07:22 PM
Does it have to do something with my grid column being a template column rather than a gridbound column?

I noticed that if I use the code then even if i change the value in my combo box my filter expression is blank.

ANy ideas?

0
Yavor
Telerik team
answered on 18 Mar 2009, 09:10 AM
Hello,

I am not sure what your setup is. However, you can either point me to a dicrepancy in the code sample which I attached earlier, or, if your setup is different, open a formal support ticket, and send us a small project, demonstrating it, for additional testing.

Greetings,
Yavor
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
Yavor
Telerik team
newbie
Top achievements
Rank 1
Share this question
or