Hi, I am getting a double filtering effect happening. Once on the server side and then one more time on the client side. This double filtering wouldn't be an issue except for one of my columns (Description) is 2000 characters long so I only pass back the first 200 characters. If the data I filtered on is after the first 200 characters then the client side filter removes the row.
I do server side filtering by using the datasource selecting event:
protected void objItems_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["sortExpression"] = RadGrid1.MasterTableView.SortExpressions.GetSortString();
e.InputParameters["filterExpression"] = RadGrid1.MasterTableView.FilterExpression;
if (e.ExecutingSelectCount)
{
// count is done last
//RadGrid1.MasterTableView.FilterExpression = "";
// while using the above line worked it failed when going from page to page
}
else
{
// selection is done first
}
}
public IList get(int catalogueId, string sortExpression, string filterExpression, int maximumRows, int startRowIndex)
{
...
}
5 Answers, 1 is accepted
What do you mean by saying that the RadGrid is filtered client-side? If it is bound to a datasource control, it filters only server-side.
Are you sure that you cancel out the default grid filtering when filtering the datasource in its selecting event handler? You should make sure that the FilterExpression string is cleared in order to prevent the grid from executing its own filtering on the set of data which is passed to it.
All the best,
Tsvetina
the Telerik team

If you look at my code example in the original post, you will see that I have commented out the filter expression clear.
//RadGrid1.MasterTableView.FilterExpression = "";
If I uncomment that line then it works as you say however when I go from one grid page to another or change the grid page size I get the full contents without filtering. By leaving the line commented I get the proper filtering but it's done twice.
Here is my radgrid in case you are interested:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
DataSourceID
=
"objItems"
GridLines
=
"None"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
EnableLinqExpressions
=
"true"
OnInit
=
"RadGrid1_Init"
OnItemCreated
=
"RadGrid1_ItemCreated"
PagerStyle-AlwaysVisible
=
"true"
PagerStyle-Position
=
"TopAndBottom"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataSourceID
=
"objItems"
DataKeyNames
=
"CatalogueItemId"
EditMode
=
"PopUp"
OverrideDataSourceControlSorting
=
"true"
ItemStyle-VerticalAlign
=
"Top"
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
ButtonType
=
"ImageButton"
ItemStyle-VerticalAlign
=
"Top"
></
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"StockNumber"
HeaderText
=
"Stock Number"
SortExpression
=
"StockNumber"
UniqueName
=
"StockNumber"
ItemStyle-VerticalAlign
=
"Top"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ProductName"
HeaderText
=
"Product Name"
SortExpression
=
"ProductName"
UniqueName
=
"ProductName"
ItemStyle-VerticalAlign
=
"Top"
ItemStyle-Height
=
"50px"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Description2"
ItemStyle-VerticalAlign
=
"Top"
DataField
=
"Description"
SortExpression
=
"Description"
HeaderText
=
"Description"
>
<
ItemTemplate
>
<
div
style
=
"height: 60px; overflow: hidden"
>
<
asp:Label
ID
=
"lblDescription"
runat
=
"server"
Text='<%# Eval("Description") %>'></
asp:Label
>
</
div
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"PartNumber"
HeaderText
=
"Part Number"
SortExpression
=
"PartNumber"
UniqueName
=
"PartNumber"
ItemStyle-VerticalAlign
=
"Top"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ISBN13"
HeaderText
=
"ISBN13"
SortExpression
=
"ISBN13"
UniqueName
=
"ISBN13"
ItemStyle-VerticalAlign
=
"Top"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this item?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
ItemStyle-VerticalAlign
=
"Top"
>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
In case you do not want to use the built-in filter expression, you should clear it on ItemCommand of the grid (when the command name is GridFilterCommandName) and then assign a filtered datasource to RadGrid in its NeedDataSource event handler.
Greetings,
Tsvetina
the Telerik team

protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName ==
"Filter"
)
{
if
(e.Item
is
GridFilteringItem)
{
GridFilteringItem item = (GridFilteringItem)e.Item;
}
}
}
but I don't know how to clear it?
You can take a look at this help article (Example 2) in order to see how to access and change the filter expression in ItemCommand event handler of RadGrid.
All the best,
Tsvetina
the Telerik team