How to hide hidden dropdownlist item?

1 Answer 48 Views
DropDownList Filter
AJ
Top achievements
Rank 1
AJ asked on 06 Sep 2022, 10:13 AM

I have a Kendo DropdownList as follows : 

    $("#txtTag").kendoDropDownList({
        dataTextField: "TagDesc",
        dataValueField: "TagId",
        optionLabel: " ",
        dataSource: {
            transport: {
                read: {
                    dataType: "json",
                    url: "/Data/GetTag"
                }
            }
        },
        change: onChange,
        filter: "contains"
    });

I have hidden one of the values by using 

$("#txtTag_listbox li")[4].hidden = true;

However, when I do a filter/search on the dropdown List , the hidden item also appears in that list. How do I prevent it to not appear it in the list.

1 Answer, 1 is accepted

Sort by
1
Accepted
Neli
Telerik team
answered on 09 Sep 2022, 07:48 AM

Hi AJ,

When filtering is performed in the DropDownList the dataBound and the filtering events are triggered. I would suggest you handle the dataBound event of the widget and hide the needed element there. 

However, note that if you are hiding the element by using an index, a different element will be hidden depending on the filtered result. Thus, in case in your scenario you need to hide an item with specific text, I would suggest you search for the element with the needed text and then hide it. Such an approach is demonstrated in the Dojo linked here

I hope this helps.


Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

AJ
Top achievements
Rank 1
commented on 09 Sep 2022, 08:29 AM

Hello Neli, 

Yes this approach works fine for me. Thank You!

Tags
DropDownList Filter
Asked by
AJ
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or