I have a need to filter one column based on what the user selects in a rad combo box. It works fine with one value selected but when two or more values are selectd it will not filter correct. I also need to do this client side so server side is not an option. I think the problem is within the "OR" clause. Anyone have any suggestions?
Thanks for any help,
D
<
telerik:GridBoundColumn
UniqueName
=
"foundin"
DataField
=
"foundin"
HeaderText
=
"Fields search term matched"
HeaderStyle-Width
=
"215px"
ItemStyle-Width
=
"215px"
FilterControlWidth
=
"215px"
AllowFiltering
=
"true"
ItemStyle-Wrap
=
"True"
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"radcombo_foundin"
runat
=
"server"
UniqueName
=
"radcombo_foundin"
Width
=
"200px"
OnClientDropDownClosed
=
"filterfoundin"
CheckBoxes
=
"true"
Filter
=
"Contains"
>
</
telerik:RadComboBox
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
function filterfoundin(sender, e) {
var tableView = $find('<%=rad_SearchResults.ClientID %>').get_masterTableView();
var filter = "Contains";
var i = 0;
var q = "";
while (i <
sender._itemData.length
) {
q += sender._itemData[i].checked ? sender._itemData[i].value : "";
if (i + 1 < sender._itemData.length) {
if (sender._itemData[i].checked) {
q += " OR ";
}
}
i++;
}
q
= q.substring(q.length - 4) == " OR " ? q.substring(0, q.length - 4) : q;
var
hidden
=
document
.getElementById('<%=hf_foundin.ClientID %>');
hidden.value = q;
tableView.filter('foundin', q, filter);
}