Preselect element from kendo ui combobox thats dynamically loaded in a "popup" kendo Window

1 Answer 60 Views
ComboBox Data Source Window
Sven
Top achievements
Rank 1
Iron
Iron
Iron
Sven asked on 18 Apr 2023, 10:11 AM

As subject says, we load the combobox in a kendo window by demand.

Hence the combobox and window are not visible by default.

I wrote a short function to preselect either the entry with ID -1 if it exists - else I want the first entry to be displayed.

My problem is the dynamic loading of all that - my commands are executed in the databound event of the combobox - but it seems not to work as expected .. when I manually enter the needed command AFTER that kendo window with the combobox is displayed it works to a 'T' but not during regular execution ..

Can you give me some hints ?

 


                 onComboBoxDataBound: function (evt) {
                    var widget = evt.sender;
                    if (this.dataSource.total() > 0) {
                        // delete preselection then try to select entry with id -1
                        $('#modComboBox').data('kendoComboBox').input.select();
                        $('#modComboBox').data('kendoComboBox').input.val('');
                        $('#modComboBox').data('kendoComboBox').select(function (data) {
                            return data.id == -1;
                        });
                        // no selection then select first entry
                        if (widget.select() === -1) { // hint I found in stackoverflow
                            $('#modComboBox').data('kendoComboBox').select(0);
                        }
                    }
                },

I tried "waiting" for the kendo window to be displayed - but that waiting seems to interfere with normal code execution and prevents the "popup display" from being executed so the kendo window content is displayed behind other stuff 

1 Answer, 1 is accepted

Sort by
0
Sven
Top achievements
Rank 1
Iron
Iron
Iron
answered on 18 Apr 2023, 02:34 PM

Found a solution - circumventing the dataBound event... 

I directly call the above code (with some slight changes because the evt doesnt exist) from the init method of the kendo window... - which is called after the data are ready. 

Tags
ComboBox Data Source Window
Asked by
Sven
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Sven
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or