Hi I have States Kendo Combox set up like below on a template ;which opens up on Grid Edit popup template.
1) For some reason even if placeholder is setup ; Combobox shows first item as Object.
2)Trying to achieve to clear the box when invalid text is entered other than in the data source.
Getstates() returns a list of states as Name and Code fields.
Template:
Model & Field:
ComboBox:
Data Array:
1) For some reason even if placeholder is setup ; Combobox shows first item as Object.
2)Trying to achieve to clear the box when invalid text is entered other than in the data source.
Getstates() returns a list of states as Name and Code fields.
Template:
<
tr
>
<
td
>
<
label
for
=
"State"
class
=
"required"
>State:</
label
>
</
td
>
<
td
>
<
input
id
=
"State"
class
=
"k-input k-textbox"
name
=
"State"
data-bind
=
"value:State"
placeholder
=
"State"
required
=
"required"
validationMessage
=
"State.."
style
=
"width:172px;"
/>
</
td
>
</
tr
>
Model & Field:
schema: {
model: { State: "State",
fields: {State: { defaultValue: { Value: "", Text: "" }, validation: { required: true} }
}
}
ComboBox:
var
crudServiceBaseUrl = window.applicationBaseUrl +
'api/WebApi'
;
$(
"#State"
).kendoComboBox({
placeholder:
"Select..."
,
dataTextField:
"Name"
,
dataValueField:
"Code"
,
dataSource: {
//severFiltering: true,
transport: {
read: {
url: crudServiceBaseUrl +
"/GetStates"
}
}
},
open:
function
(e) {
valid =
false
;
},
select:
function
(e) {
valid =
true
;
},
change:
function
(e) {
var
arrayOfStrings = $.map(
this
.dataSource.data(),
function
(val) {
return
val.dataTextField });
if
(arrayOfStrings.indexOf(
this
.value()) == -1) {
this
.value(
''
);
}
},
filter:
"startswith"
,
suggest:
true
,
index: 0
});
Data Array:
data: [{ Name:
"Alabama, AL"
, Code:
"AL"
},{ Name:
"Alaska, AK"
, Code:
"AK"
},]