The comboBox value selected doesn't always match what the client entered.

1 Answer 14 Views
ComboBox Filter
Noah
Top achievements
Rank 1
Iron
Noah asked on 21 May 2024, 01:52 PM
The selected value in the comboBox may not always reflect what the client entered due to a timing issue. For instance, if the client enters a value and presses enter before the filtering process is completed, they may not receive the intended value. Instead, they may receive the top value in the filtered results.

Does anyone know a dependable solution to resolve this issue?
Nikolay
Telerik team
commented on 24 May 2024, 11:26 AM

Hi Noah,

When the user hits enter the selected value will always be the top value from the list unless they navigate to a different value.

Additionally, selecting a value from the list is possible only when the whole list is loaded with the filtered data.

https://demos.telerik.com/kendo-ui/combobox/serverfiltering

Please let me know if case I am missing something.

Regards,

Nikolay

Noah
Top achievements
Rank 1
Iron
commented on 03 Jun 2024, 03:09 PM

Thank you for the response.

I should have provided more details in my initial question. What you describe is the issue I ran into. the user would type faster than the filter and hit enter. Causing the selected value to be the wrong value. any solution I tried using the Kendo events wasn't sufficient. I did end up with a solution, albeit one I'm not thrilled with, but it works so if someone can tell me how to do this without circumventing Telerik I would be happy to try it. 

1 Answer, 1 is accepted

Sort by
0
Accepted
Noah
Top achievements
Rank 1
Iron
answered on 03 Jun 2024, 03:05 PM
I did end up making my own solution to handle this issue.
I capture data using the input, key up, and change events of the visible combo box input. I use this data to then verify inputs when the combo box control triggers its own change event.,

comboboxelement.parent().on("input keyup", ".k-input-inner", (e) => {
	const targetInput = $(e.currentTarget);
	if (e.key) {
		if (e.key === "Enter") {
			return targetInput.trigger("change");
		} else {
			return true;
		}
	}

	let val = targetInput.val();
	targetInput.data("key-val", val);
});

comboboxelement.parent().on("change", ".k-input-inner", (e) => {
	const targetInput = $(e.currentTarget);
	const comboBox = targetInput.nextAll("input").data("kendoComboBox");
	comboBox.value(targetInput.data("key-val"));
	comboBox.trigger("change");
})

Tags
ComboBox Filter
Asked by
Noah
Top achievements
Rank 1
Iron
Answers by
Noah
Top achievements
Rank 1
Iron
Share this question
or