i tried using this method in creating a Custom Filter Column
http://www.telerik.com/help/aspnet/grid/grdfilteringwithdropdownlist.html
and it works fine but when i tried using the radcombobox instead of MS DropDown List the selceted index changed doesn't works so can anyone help me in this
public
class
FilteringTemplateColumns : GridBoundColumn
{
string
_dataSourceID;
public
string
DataSourceID
{
get
{
return
_dataSourceID; }
set
{ _dataSourceID = value; }
}
string
_dataTextField;
public
string
DataTextField
{
get
{
return
_dataTextField; }
set
{ _dataTextField = value; }
}
string
_dataValueField;
public
string
DataValueField
{
get
{
return
_dataValueField; }
set
{ _dataValueField = value; }
}
protected
override
void
SetupFilterControls(TableCell cell)
{
base
.SetupFilterControls(cell);
cell.Controls.RemoveAt(0);
RadComboBox rcBox =
new
RadComboBox();
rcBox.ID =
"cmb"
+
this
.DataField;
rcBox.AutoPostBack =
true
;
rcBox.DataTextField = DataTextField;
rcBox.DataValueField = DataValueField;
rcBox.SelectedIndexChanged +=
new
RadComboBoxSelectedIndexChangedEventHandler(rcBox_SelectedIndexChanged);
rcBox.DataSourceID = DataSourceID;
rcBox.AppendDataBoundItems =
true
;
rcBox.Items.Insert(0,
new
RadComboBoxItem(
""
,
""
));
rcBox.Items.Insert(1,
new
RadComboBoxItem(
"All"
,
"All"
));
cell.Controls.AddAt(0, rcBox);
cell.Controls.RemoveAt(1);
}
void
rcBox_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox list = sender
as
RadComboBox;
GridFilteringItem filterItem = (sender
as
RadComboBox).NamingContainer
as
GridFilteringItem;
if
(
this
.DataType == System.Type.GetType(
"System.Int32"
) ||
this
.DataType == System.Type.GetType(
"System.Int16"
) ||
this
.DataType == System.Type.GetType(
"System.Int64"
))
{
filterItem.FireCommandEvent(
"Filter"
,
new
Pair(
"EqualTo"
,
this
.UniqueName));
}
else
// treat everything else like a string
{
if
(list.SelectedValue !=
"All"
)
filterItem.FireCommandEvent(
"Filter"
,
new
Pair(
"Contains"
,
this
.UniqueName));
else
filterItem.FireCommandEvent(
"Filter"
,
new
Pair(
"NoFilter"
,
this
.UniqueName));
}
}
protected
override
void
SetCurrentFilterValueToControl(TableCell cell)
{
base
.SetCurrentFilterValueToControl(cell);
RadComboBox list = (RadComboBox)cell.Controls[0];
if
(
this
.CurrentFilterValue !=
string
.Empty)
{
list.Items.Clear();
list.AppendDataBoundItems =
true
;
list.DataBind();
list.SelectedItem.Text =
this
.CurrentFilterValue;
list.Items.Insert(0,
new
RadComboBoxItem(
""
,
""
));
list.Items.Insert(1,
new
RadComboBoxItem(
"All"
,
"All"
));
}
}
protected
override
string
GetCurrentFilterValueFromControl(TableCell cell)
{
RadComboBox list = (RadComboBox)cell.Controls[0];
return
list.SelectedItem.Text;
}
protected
override
string
GetFilterDataField()
{
return
this
.DataField;
}
}