I'm expiriencing the following problem
I have Grid and 2 filters. Second filter is being filled based on selected value in first one.
Here is the code
All is working fine untill you change First filter selected value (in case value in second filter was changed). It throws "Selection out of range Parameter name: value".
I even tried to add items to the second combobox manually (instead of binding it). In this case on code behind it doesn't throw exception but it does throw it on client side (javascript). Error is the same.
I've tried almost everything but still cannot make it work.
I have Grid and 2 filters. Second filter is being filled based on selected value in first one.
Here is the code
protected
void
OnItemCreated(
object
sender, GridItemEventArgs e)
{
GridFilteringItem item = e.Item
as
GridFilteringItem;
if
(item !=
null
)
{
RadComboBox planIdCombo = (RadComboBox)item.FindControl(
"planIdFilterComboBox"
);
RadComboBox pbpIdCombo = (RadComboBox)item.FindControl(
"pbpIdFilterComboBox"
);
planIdCombo.DataSource = SNPConfigView.Select(t => t.PlanID).Distinct().OrderBy(t => t);
planIdCombo.DataBind();
planIdCombo.SelectedValue = e.Item.OwnerTableView.GetColumn(
"PlanId"
).CurrentFilterValue;
pbpIdCombo.DataSource = SNPConfigView.Where(t => t.PlanID == planIdCombo.SelectedValue ||
string
.IsNullOrEmpty(planIdCombo.SelectedValue)).Select(t => t.PBPID).Distinct().OrderBy(t => t);
pbpIdCombo.DataBind();
pbpIdCombo.SelectedValue = e.Item.OwnerTableView.GetColumn(
"PbpId"
).CurrentFilterValue;
}
}
All is working fine untill you change First filter selected value (in case value in second filter was changed). It throws "Selection out of range Parameter name: value".
I even tried to add items to the second combobox manually (instead of binding it). In this case on code behind it doesn't throw exception but it does throw it on client side (javascript). Error is the same.
I've tried almost everything but still cannot make it work.
<
telerik:GridBoundColumn
DataField
=
"PlanId"
HeaderText
=
"Plan ID"
UniqueName
=
"PlanId"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"EqualTo"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"70px"
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"planIdFilterComboBox"
Width
=
"60"
AppendDataBoundItems
=
"True"
OnItemDataBound
=
"OnPlanIdFilterComboItemDataBound"
SelectedValue='<%# Container.OwnerTableView.GetColumn("PlanId").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="PlanIdFilterComboIndexChanged">
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"All"
Value
=
""
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"planIdFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function PlanIdFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("PlanId", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PBPID"
HeaderText
=
"PBP"
UniqueName
=
"PBPID"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"Contains"
ShowFilterIcon
=
"false"
FilterControlWidth
=
"40px"
>
<
HeaderStyle
Width
=
"70px"
></
HeaderStyle
>
<
ItemStyle
CssClass
=
"center"
></
ItemStyle
>
<
FilterTemplate
>
<
telerik:RadComboBox
ID
=
"pbpIdFilterComboBox"
Width
=
"60"
EnableViewState
=
"False"
OnItemDataBound
=
"OnPbpIdFilterComboItemDataBound"
SelectedValue='<%# Container.OwnerTableView.GetColumn("PBPID").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="PbpIdFilterComboIndexChanged">
</
telerik:RadComboBox
>
<
telerik:RadScriptBlock
ID
=
"pbpIdFilteringScripBlock"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function PbpIdFilterComboIndexChanged(sender, args) {
var tableView = $find("<%# Container.OwnerTableView.ClientID %>");
tableView.filter("PBPID", args.get_item().get_value(), "EqualTo");
}
</
script
>
</
telerik:RadScriptBlock
>
</
FilterTemplate
>
</
telerik:GridBoundColumn
>