Bug after update telerik version, radcombobox not keeping values on filters Radfilter

0 Answers 77 Views
Filter
Maximiliano
Top achievements
Rank 1
Maximiliano asked on 24 Oct 2023, 07:15 PM

Hi, we found a problem after updating our project to our last available version witch is "Complimentary R1 2020 Version", we are on 2016.2.607.40, and after find a problem in radgrid and keyboard interaction we look at out download page and have the complimentary version, we try it and that problem solves, but in a recently added radfilter we discover that stop working as spectated.

 

We use RadFilterDropDown with radcomboboxes, which load on demand.

First, we see that load settings displays the saved info of combos in blank.

Second, we discover also that selecting a item from combo, not saving on settings and not showing on preview also

 

With 2016.2.607.40

With Trial version of 2023.3.1010 (we try it to see if problem solved on last version)

 

Attached isolated sample for reproduction
Rumen
Telerik team
commented on 04 Aug 2025, 01:12 PM

For the benefit of the community, I'm sharing the solution provided in the related support ticket:

There have been multiple changes made to the ComboBox and Filter over the years, hence the difference between the behavior. Also, while inspecting the source code, we noticed that the LoadOnDemand is not supported for the RadFilterDropDownEditor, and it should not have worked in the past either. 

Nevertheless, to create a FieldEditor with ComboBox and LoadOnDemand, you will have to implement the FieldEditor by creating a Custom Field Editor.

Example:

 

public class LoadOnDemandFieldEditor : RadFilterDropDownEditor
{
    private RadComboBox _combo;
    public string DataTextField
    {
        get
        {
            return (string) ViewState["DataTextField"] ?? string.Empty;
        }
        set
        {
            ViewState["DataTextField"] = value;
        }
    }
    public string DataValueField
    {
        get
        {
            return (string) ViewState["DataValueField"] ?? string.Empty;
        }
        set
        {
            ViewState["DataValueField"] = value;
        }
    }
    public DataTable DataSource
    {
        get
        {
            return (DataTable) ViewState["DataSource"] ?? new DataTable();
        }
        set
        {
            ViewState["DataSource"] = value;
        }
    }

    protected override void CopySettings(RadFilterDataFieldEditor baseEditor)
    {
        base.CopySettings(baseEditor);

        var editor = baseEditor as LoadOnDemandFieldEditor;

        if (editor != null)
        {
            DataSource = editor.DataSource;
            DataTextField = editor.DataTextField;
            DataValueField = editor.DataValueField;
        }
    }

    public override ArrayList ExtractValues()
    {
        return new ArrayList()
        {
            _combo.SelectedValue
        };
    }

    public override void InitializeEditor(Control container)
    {
        _combo = new RadComboBox();
        _combo.ID = "MyCombo";
        _combo.EnableLoadOnDemand = true; // Enable LoadOnDemand
        _combo.ItemsRequested += _combo_ItemsRequested; // Attach the ItemsRequested event
        container.Controls.Add(_combo);
    }

    private void _combo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        var combo = (RadComboBox) sender;

        // Populate the Combo with items based on the datasource
        foreach (DataRow row in DataSource.Rows)
        {
            combo.Items.Add(new RadComboBoxItem(row[DataTextField].ToString(), row[DataValueField].ToString()));
        }
    }
    public override void SetEditorValues(ArrayList values)
    {
        if (values != null && values.Count > 0)
        {
            if (values[0] == null)
                return;

            var item = _combo.FindItemByValue(values[0].ToString());

            if (item != null)
                item.Selected = true;
        }
    }
}

 

 

Usage:

 

protected void Page_Init(object sender, EventArgs e)
{
    var comboLoadOnDemandEditor = new LoadOnDemandFieldEditor();
    comboLoadOnDemandEditor.FieldName = "GIA_PRDELE1";
    comboLoadOnDemandEditor.DisplayName = "Familia";
    comboLoadOnDemandEditor.DataTextField = "Text";
    comboLoadOnDemandEditor.DataValueField = "Value";
    comboLoadOnDemandEditor.DataSource = GetComboData();
    comboLoadOnDemandEditor.DataType = typeof(string);

    ftProductos.FieldEditors.Add(comboLoadOnDemandEditor);
}

protected void ftProductos_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e)
{
    if (e.EditorType == "LoadOnDemandFieldEditor")
    {
        e.Editor = new LoadOnDemandFieldEditor() { DisplayName = "Familia" };
    }
}

 

The same approach should have been used with earlier versions too, and it would work now.

Please give this a try and if you have any questions, let me know.

 

No answers yet. Maybe you can help?

Tags
Filter
Asked by
Maximiliano
Top achievements
Rank 1
Share this question
or