
Hi,
I have problem for RadGrid filtering, even I set CurrentFilterFunction="StartsWith", but filtering always filter as "contains", here is my code for RadGrid, is anything wrong?
thanks
<telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1"
Width="800px" AllowFilteringByColumn="True" AllowSorting="True"
ShowFooter="True" AllowPaging="True" runat="server"
GridLines="None" EnableLinqExpressions="false">
<GroupingSettings CaseSensitive="false" />
<MasterTableView AutoGenerateColumns="false" EditMode="InPlace" AllowFilteringByColumn="True"
ShowFooter="True" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn FilterControlWidth="60px" DataField="DONOR" HeaderText="DONOR" SortExpression="DONOR"
UniqueName="DONOR" AutoPostBackOnFilter="true" CurrentFilterFunction="StartsWith" ShowFilterIcon="false">
</telerik:GridBoundColumn>
........
17 Answers, 1 is accepted

Are you facing an issue similar to the one mentioned in the forum link.If so the Telerik team has offered a solution
CurrentFilterFunction defaults back to Contains?
If this doesnot help could you mention the steps performed to achieve filtering
Thanks,
Princy

1.
Would you please provide any sample client side script to disable postback from enter key press inside filter textboxes?
2.
or Would you please provide any sample client side script to check the value of the filter textbox, and cancel out the bubbling of the enter key press if there is no value?
Thanks
daniel

Is it anyway to enforce CurrentFilterFunction="StartsWith" from server side C# code?
thanks
daniel

After I tested filter more than 10 times, following javascript scripting error thrown:
j.href=j.href.replace(
"&ie7CacheFix","")
seems filter function is not matual yet.
thanks
daniel

We could not use DataSourceID as your basic filtering sample, What I did is to bind RadGrid from c# code :
protected void Page_Load(object sender, EventArgs e)
{
loadGrid();
}
The filter function is not working this way.
If you try bind RadGrid from c# codebehind, you would see the problems.
thanks
daniel

Simple data-binding cannot be used to perform complex operations such as filtering. Thus, try binding the Grid in the NeedDataSource event of the grid and see if it makes any difference. You can refer the following online demo to find out more on AdvanceDataBinding techniques.
Advanced data-binding
Thanks
Princy.

I used NeedDataSource as following, but still the same problem, CurrentFilterFunction="StartsWith" only works for the first time filtering, if I try to filter any textbox after first time filtering, it becomes CurrentFilterFunction="Contains".
Would you please test it on your side and give us the correct answer to fix this bug???
thanks for your quick response!
daniel
<telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource"
Width="800px" AllowFilteringByColumn="True" AllowSorting="True"
ShowFooter="True" AllowPaging="True" runat="server"
GridLines="None" EnableLinqExpressions="false">
<GroupingSettings CaseSensitive="false" />
<MasterTableView AutoGenerateColumns="false" EditMode="InPlace" AllowFilteringByColumn="True"
ShowFooter="True" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn FilterControlWidth="60px" DataField="DONOR" HeaderText="DONOR" SortExpression="DONOR"
UniqueName="DONOR" AutoPostBackOnFilter="true" CurrentFilterFunction="StartsWith" ShowFilterIcon="false">
</telerik:GridBoundColumn>
......
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
IQueryable<COG_ACTION_STAGE_VW> query = GetDataForGrid();
this.RadGrid1.DataSource = query;
}

It only has "Contains" filtering with ShowFilterIcon="false" for Textbox filter,
did you ever tested
CurrentFilterFunction="StartsWith" ShowFilterIcon="false"???
thanks
daniel
In order to make this work after the filter of the Grid is cleared you should set the CurrentFilterFunction for the respective column on the PreRender event handler of the page similar to the following:
protected
void
Page_PreRender(
object
sender, EventArgs e)
{
RadGrid1.Columns[0].CurrentFilterFunction = Telerik.Web.UI.GridKnownFunction.StartsWith;
}
Sincerely yours,
Pavel
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

thanks


You can go through the following help document which explains on how to reduce the filter options in the filter menu:
Reducing the filter menu options
-Princy.


But why the initialized currentfilterfunction property loses its value
is this a bug ?
The observed behavior is the expected one when the CurrentFilterFunction property is set in the markup. If you want to persist it you need to use the approach suggested previously.
Sincerely yours,
Pavel
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.

In order to set the default filter function for a column you could use itsCurrentFilterFunction property. I tested the following setup and it seems to work as expected on my end. The Description column was filtered using the StartsWith function. I used the 2014.1.225 version of the controls for testing.
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGrid1"
Skin
=
"Default"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
AutoGenerateColumns
=
"false"
AllowPaging
=
"true"
PageSize
=
"10"
AllowFilteringByColumn
=
"true"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
DataKeyNames
=
"ID"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
HeaderText
=
"ID"
UniqueName
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
AutoPostBackOnFilter
=
"true"
ShowFilterIcon
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Description"
HeaderText
=
"Description"
UniqueName
=
"Description"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"StartsWith"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
For convenience I am also attaching the sample project I tested with. Give it a try and let me know if it is working for you.
Regards,
Viktor Tachev
Telerik
DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.