I have a RadGrid with several columns. Some of them have comboboxes and some of them have textboxes as filter input. If I first filter using one item from Combobox, such as state "Florida" and then I try to filter again using the textbox and input a searchable word it works fine and bring me the result. However if the word is not searchable I get the error below.
6 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 25 Feb 2014, 05:46 AM
Hi Paulo,
I was not able to replicate such an issue at my end. Below is a sample code snippet that I tried, please try it. Provide your code as well as steps to reproduce the issue if the problem is not solved.
ASPX:
Thanks,
Princy
I was not able to replicate such an issue at my end. Below is a sample code snippet that I tried, please try it. Provide your code as well as steps to reproduce the issue if the problem is not solved.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"true"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"OrderID"
DataField
=
"OrderID"
HeaderText
=
"OrderID"
/>
<
telerik:GridBoundColumn
DataField
=
"ShipCity"
HeaderText
=
"ShipCity"
UniqueName
=
"ShipCity"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"ShipName"
DataField
=
"ShipName"
SortExpression
=
"ShipName"
HeaderText
=
"ShipName"
ShowFilterIcon
=
"false"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblInclude"
runat
=
"server"
Text='<%#Eval("ShipName")%>' />
</
ItemTemplate
>
<
FilterTemplate
>
<
telerik:RadTextBox
ID
=
"txtIncludeFileFilter"
Text='<%# Container.OwnerTableView.GetColumn("ShipName").CurrentFilterValue %>' runat="server" AutoPostBack="false" onkeydown="filterTxtBox(event,this);">
</
telerik:RadTextBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function filterTxtBox(event, sender) {
if (event.keyCode == 13)
{
var filterValue = "";
var filterFunction = "NoFilter";
var s = sender.value;
if (s != "") {
filterValue = s;
var filterFunction = "Contains";
}
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("ShipName", filterValue, filterFunction);
}
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"ShipCountry"
UniqueName
=
"ShipCountry"
HeaderText
=
"ShipCountry"
AutoPostBackOnFilter
=
"true"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"RC1"
runat
=
"server"
DataValueField
=
"ShipCountry"
AppendDataBoundItems
=
"true"
DataTextField
=
"ShipCountry"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ShipCountry").CurrentFilterValue %>' OnClientSelectedIndexChanged="filterComboBox">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function filterComboBox(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("ShipCountry", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Thanks,
Princy
0

Paulo
Top achievements
Rank 1
answered on 25 Feb 2014, 10:52 AM
Princy thank you. My combo box is populated by an ibjectdatasource, which has a function to return the data base on the filter expression. I notice yesterday during my debug that if the free expression has a value that is not in the dataset it crashes after returning the dataset, I will keep debugging it today but if you have any thought that could help I apreciate
0

Paulo
Top achievements
Rank 1
answered on 25 Feb 2014, 04:54 PM
Princy Just as a feedback. I got a work around. The problem was: the comboboxes are populated based on the previous filter expression. So when I input a string in the textbox which wont find anything it was crashing because there were no values to populate de comboboxes. So I tricked my code behind to populate the comboboxes with the previous value in case the new filter expression couldn't find anything.
Now it works fine...
Now it works fine...
0
Hi Paulo,
I'm glad that you've managed to overcome the issue.
Basically, In similar scenarios you should use the CurrentFilterValue of the related column to set the selected item of the combo, and not the FilterExpression of the entire GridTableView.
Hope this helps.
Regards,
Eyup
Telerik
I'm glad that you've managed to overcome the issue.
Basically, In similar scenarios you should use the CurrentFilterValue of the related column to set the selected item of the combo, and not the FilterExpression of the entire GridTableView.
Hope this helps.
Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0

Paulo
Top achievements
Rank 1
answered on 27 Feb 2014, 09:23 PM
Princy
Thank you. Do you have any example for that?
Thank you. Do you have any example for that?
0
Hello Paulo,
You can check the following sample where the mentioned approach is implemented:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx
Regards,
Eyup
Telerik
You can check the following sample where the mentioned approach is implemented:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx
Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.