Is it possible to conditionally show and hide items in a Kendo form based upon the data?
For example, if I have a form to enter a Person or a Company, I want to hide the Address field if it is a Company, or hide the Contact field if it is a Person.
Also please note that if attributes are used to try to set the field to display:none as in the example here., it only hides the editor, not the label or hint.
<form id="myForm"></form>
<script>
$("#myForm").kendoForm({
formData: {
Name: "John Doe",
Address: "123 Main St.",
Contact: "",
Type: 1 // 1 = Person, 2 = Company
},
items: [{
field: "Name",
hint: "Enter Full Name",
}, {
field: "Address",
hint: "Enter Address with ZIP Code",
attributes:{
// need to hide this field if the Type = 2
class: "person"
}
}, {
field: "Contact",
hint: "Enter the Company Contact",
attributes:{
// need to hide this field if the Type = 1
class: "company"
}
}]
});
</script>
<style>
.person {
display: block;
}
.company{
display: none;
}
</style>