This is a migrated thread and some comments may be shown as answers.

RadComboBox for custom RadFilterDataFieldEditor changing to Textbox

1 Answer 70 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 09 Oct 2012, 09:45 PM

I have a RadFilter with a custom FieldEditor control inside the <FieldEditors></FieldEditors> tags.

The custom field control is a class inherited from RadFilterDataFieldEditor.

In the InitializeEditor(System.Web.UI.Control container) method, a RadComboBox is instantiated and
added to the Controls collection of the container parameter.   The DataTextField property of the RadComboBox is text while the DataValueField property of the RadComboBox is a numeric value corresponding to the text's numeric ID.

When a filter expression is added, the dropdown listbox is displayed for selecting the filter value as the text.  However once the RadFilter Apply button is clicked on postback, the combobox changes to a textbox with the numeric value.

Can't figure out why this is happening.  Could use some help!  Thanks in advance.

 

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 12 Oct 2012, 12:12 PM
Hello Lee,

This sounds like a problem related to instantiating the field editor correctly. Can you confirm that you follow closely the event sequence from our sample of custom field editors:
Filter / Custom Field Editors

Make sure that you either declare the editor in mark-up, or declare it on initial Page_Load:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        RadFilterDropDownEditor dropDownFieldEditor = new RadFilterDropDownEditor();
        RadFilter1.FieldEditors.Add(dropDownFieldEditor);
        dropDownFieldEditor.FieldName = "Country";
        dropDownFieldEditor.DataTextField = "Country";
        dropDownFieldEditor.DataValueField = "Country";
        dropDownFieldEditor.DataSource = GetEmployeesDataTable().DefaultView.ToTable(true, "Country");
     }
}

Then, on FieldEditorCreating you should always instantiate the editor:
protected void RadFilter1_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e)
{
    if (e.EditorType == "RadFilterDropDownEditor")
    {
        e.Editor = new RadFilterDropDownEditor();
    }
}

Additionally, when following these instructions, make sure that you have ViewState enabled for the filter.

All the best,
Tsvetina
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Filter
Asked by
Lee
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or