Unplanned
Last Updated: 27 Nov 2024 15:35 by ADMIN
Nico
Created on: 26 Nov 2024 07:55
Category: ComboBox
Type: Feature Request
1
ComboBox: Provide an option for programmatic filtering

At the moment, the SelectedItem is not displayed (as readonly text in the entry text) if it is not present in the ItemSource.I suspect this is by design (but maybe a bug?) Background: In my list there are elements that are readonly, i.e. can correspond to the current selection, but cannot be selected by the user if a change is made.At the moment, the ItemSource has to be cleaned of the readonly elements before it is assigned to the ComboBox.A suggested solution would therefore be: Add a FilterDescriptors property, as in the RadCollectionView. This is taken into account in the selection list, but not for the display of the SelectedItem

Dirty workarround vor the moment:


private void cb_Loaded(object sender, EventArgs e)
{
    if (sender is RadComboBox radComboBox)
    {
        IReadOnlyList<IVisualTreeElement> children = radComboBox.GetVisualTreeDescendants();
        RadEntry entry = children.OfType<RadEntry>().FirstOrDefault();
        //entry.Text = DataContextViewModel.SelectedFieldOptionText;
        entry?.Bind(RadEntry.TextProperty, static (IComboBoxViewModel x) => x.SelectedOptionText, source: DataContextViewModel);
    }
}

4 comments
Nico
Posted on: 27 Nov 2024 13:29
perfect, thx Didi
ADMIN
Didi
Posted on: 27 Nov 2024 12:44

Hello Nico,

Thank you for the update. I talked to the dev team and I have updated the title of this feature request to provide an option for programmatic filtering.

For now as a solution use the approach you found.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Nico
Posted on: 27 Nov 2024 12:00

Hi Didi,

thx for this approach which i've missed.
Unfortunately this only works if IsEditable is set to true and the user enters some text.

else if (IsFilteringEnabled && IsEditable && !flag)
        {
            Filter(Text);
        }

this doesn't work in my scenario where IsEditable is false (need this, otherwise the entry may captures the focus, what is not wanted).
A possibility of this filtering behavior without IsEditable=true and the text empty flag would solve my use case

kind regards
Nico

ADMIN
Didi
Posted on: 27 Nov 2024 11:38

Hi Nico,

Thank you for the provided code and details.

The Telerik RadComboBox expose filtering. Could you please give the custom filtering approach a try and let me know if this approach helped achieve the scenario?

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.