Hi,
I've recently found an issue with the combobox where a user can type in any number on the combobox and it will save if the foreign key exists on the database - regardless of checking whether or not the value is valid for use or not.
Why does the combobox treat typing in a random number as the FK of the control anyway when it doesn't do the same thing if you type in a random character?
Anyway the above is a question for a different time but after finding this out, I've found there's an article on how to avoid these kind of situations using JavaScript on this page:
https://docs.telerik.com/kendo-ui/knowledge-base/prevent-submission-of-missing-value
While trying to implement this logic, I can see that it's working (by not allowing the random number selection to be saved), but I've noticed there's actually an error on the first round of "select" call as the loading icon is displayed on the combo box.
The specific line is the "this.select(0)" line from the code snippet below:
if
(
this
.value() &&
this
.selectedIndex == -1) {
this
.dataSource.filter({
value:
this
.value(),
field:
this
.options.dataTextField,
operator:
"contains"
});
this
.select(0); <===
this
line is causing the issue.
if
(
this
.selectedIndex == -1 ) {
this
.text(
""
);
}
}
Upon closer inspection, I see that there's a 500 error being thrown due to the "Page" parameter being set to NaN and the "PageSize" parameter being set to 0.
https://
.../Items?sort=&group=&filter=NameDisplay~contains~%2712%27&page=NaN&pageSize=0
Any subsequent searches works without any issues and sets the "Page" and "PageSize" to the correct values.
https:
//.../Items?sort=&page=1&pageSize=80&group=&filter=NameDisplay~contains~%2712%27
This is very strange as the 500 error (above) only displays the first time this.select(0) is called, but any subsequent times will work without any issues.
While trying to reproduce this, I've found that it only occurs when the combobox has a valuemapper set to it.
.Virtual(v => v.ItemHeight(26).ValueMapper(
"itemsValueMapper"
))
When the valuemapper function is removed from the combobox, the this.select(0) functions runs without any issues.
The value mapper is required for my comboboxes as it provides a good way to virtualise my lists.
My datasource is using webapi as below:
.DataSource(source =>
{
source.Custom()
.ServerFiltering(
true
)
.ServerPaging(
true
)
.PageSize(80)
.Type(
"webapi"
)
.Transport(transport =>
{
transport.Read(a => a.Url(itemsUrl));
})
.Schema(schema =>
{
schema.Data(
"Data"
)
.Total(
"Total"
);
});
})
Is there any work around that can be done for this?
Or even better, is there a way to prevent the combobox from binding random number values typed into the control?