Weird Combobox UI Behavior after a value is set on DataBind

0 Answers 28 Views
ComboBox
Donald
Top achievements
Rank 1
Donald asked on 26 Apr 2022, 11:35 PM

Hey all,

I'm fairly new to kendo and have a bit of an problem ->

I'm currently troubleshooting a weird issue in version 2019.1.220.  I'd love to upgrade but its not feasible for this project at this time.

Basically, what is going on is that we're seeing some weird behavior with the Combobox control after databind.  Data comes from the database and is set in the control.  When the Arrow (Open button) is clicked its almost as though it doesn't do a read on the datasource because I get the No items found message.  However, if I change the selected text on the control it will do a pop open and locate the item in the list.

While trying to solve this with a work around I have tried to subscribe to the click event on the control and force a search function call in Kendo using the following:

    $(document).ready(function () {
        var itemCombo = $("#Items").data("kendoComboBox");
        itemCombo.input.on("click", function () {
            itemCombo.search(itemCombo.text);
        });
    });

This does seem to force a search to run on click of the control - however the arrow button on the control still does what it did before - not read the list or search for the item.  Does anyone have any quick tips on how i can access the click event on the arrow button itself?  The Open event isn't a good option - if I call .search on that it will cause an endless loop activity.

I'm sure this has been solved already in later versions but upgrade is not an option at this time.

Appreciative of any pointers!  Thanks!

Donald
Top achievements
Rank 1
commented on 27 Apr 2022, 12:47 PM | edited

Providing this work around - hopefully it helps someone if they ever run into the same thing:

    $(document).ready(function () {
        //Locate the Combobox
        var itemCombo = $("#Items").data("kendoComboBox");

        //Tie into the click event on the input portion of the control and perform search - this solves the control not loading items initially in that instance
        itemCombo.input.on("click", function () {
            itemCombo.search(itemCombo.text);
        });

        //Tie into the mousedown event on the dropdown arrow button, get the index of the selected, perform search if only the first time or nothing selected
        //selectedindex must be evaluated as the control itself in this version resolves this internal issue on text change events.
        //evaluation prevents endless loop inside kendoui control internals
        itemCombo.wrapper.find(".k-select").on("mousedown", function (e) {
            var selectedIndex = itemCombo.select();
            if (selectedIndex <= 0) {
                itemCombo.search(itemCombo.text);
            }
        });
    });
Neli
Telerik team
commented on 29 Apr 2022, 09:52 AM

I am glad to hear you have managed to find a solution to the issue and thank you for sharing it with the community. I am sure it will be helpful to the other users in the forum.

Regards,

Neli

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Donald
Top achievements
Rank 1
Share this question
or