I was checking Telerik UI for ASP.NET AJAX Q1 2014 trial version.
I need custom paging with sorting and filtering using Stored Procedure.
i found that RadGrid filters already filtered data on its own. if custom paging is used, obviously sorting and filtering done in Stored Procedure.
is there any way to stop Radgrid to filter data on its own somthing like FilterMode="Custom" ?
4 Answers, 1 is accepted
For canceling the default filter functionality of the grid you should handle the server-side OnItemCommand event and if the command name equals RadGrid.FilterCommandName to cancel the command.
Following is a simple example of the above approach:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"true"
DataSourceID
=
"SqlDataSource1"
OnItemCommand
=
"RadGrid1_ItemCommand"
>
</
telerik:RadGrid
>
And the code-behind:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.FilterCommandName)
{
e.Canceled =
true
;
Pair filterPair = (Pair)e.CommandArgument;
string
filterFunction = filterPair.First.ToString();
string
column = filterPair.Second.ToString();
string
inputElementValue = ((e.Item
as
GridFilteringItem)[column].Controls[0]
as
TextBox).Text;
}
}
As you could notice, in the ItemCommand event handler I have shown how to retrieve the data that you will need for your custom filtering.
Hope that helps.
Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Yes, no it isn't that helpful as this results in the column.CurrentFilterValue and column.CurrentFilterFunction being blank.
When doing virtual paging, it's quite obvious that you are going to need to do filtering and sorting in the database. It's also quite obvious that if you are doing virtual paging you will not need the grid to perform filtering operations and that such operations might even be undesirable.
In my instance they are indeed undesirable and are causing an issue. I'm trying to filter a date column which contains times down to millisecs, I handle the rounding issue in the database, but the grid doesn't resulting in results that should be in the page being omitted and not displayed, because they are filtered by the radgrid.
I don't understand why Telerik goes to the trouble of providing the ability to do virtual paging, but makes it so hard to get it to work properly.
Regards
Mick

OK. Helpful it was helpful
I ended up with...
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
e.Canceled = true;
Pair filterPair = (Pair)e.CommandArgument;
string filterFunction = filterPair.First.ToString();
string column = filterPair.Second.ToString();
string inputElementValue = ((e.Item as GridFilteringItem)[column].Controls[0] as TextBox).Text;
var gridColumn = gvAuditTrail.MasterTableView.Columns.FindByUniqueName(column);
GridKnownFunction function; if (Enum.TryParse(filterFunction, out function)) }
}
This all seems overly coimplicated a simple option or just ​don't filter items in the grid when AllowCustomPaging="true".

OK. Helpful it was helpful
I ended up with...
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.FilterCommandName)
{
Pair filterPair = (Pair)e.CommandArgument;
string filterFunction = filterPair.First.ToString();
string column = filterPair.Second.ToString();
string inputElementValue = ((e.Item as GridFilteringItem)[column].Controls[0] as TextBox).Text;
var gridColumn = gvAuditTrail.MasterTableView.Columns.FindByUniqueName(column);
gridColumn = inputElementValue;
GridKnownFunction function;
if (Enum.TryParse(filterFunction, out function))
gridColumn.CurrentFilterFunction = function;
e.Canceled = true;
RadGrid1.DataSource = null;
RadGrid1.Rebind();
}
}
That seems like 23 lines of code more than should be needed to me a simple option or just don't filter items in the grid when AllowCustomPaging="true".