need to have the ability we have in a grid, to set the field to "string" or object EXPLICITLY
P.S seems right now it is under self determination based on fields value & if the field is null & editor DropDown, the object will be set instead of just value
1 Answer, 1 is accepted
Hi, Aleksandr,
The data type of the fields can be set through the underlying dataSource schema configuration:
dataSource: {
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
UnitPrice: { type: "number", validation: { required: true, min: 1} },
Discontinued: { type: "boolean" },
UnitsInStock: { type: "number", validation: { min: 0, required: true } }
}
}
}
}
Best Regards,
Georgi Denchev
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hello Georgi,
please confirm that it is possible, I am looking at the forms API doc & can't see a data source option:
https://docs.telerik.com/kendo-ui/api/javascript/ui/form?_ga=2.158395000.336107526.1673130214-1931469790.1620243254&_gl=1*1e1i6e3*_ga*MTkzMTQ2OTc5MC4xNjIwMjQzMjU0*_ga_9JSNBCSF54*MTY3MzUzNzg0MC44Ni4xLjE2NzM1Mzc4NTQuNDYuMC4w
Hi, Aleksandr,
My apologies about the misunderstanding on my end.
No, it isn't possible to explicitly set a "field" type in the Form component.
However, the described problem could be potentially resolved by configuring the valuePrimitive option of the DropDownList.
You can set it through the editorOptions of the Form field.
When valuePrimitive is set to true, the model will be updated with the value from the dataValueField. When it is set to false, the model is updated with the entire object.
Let me know if this works for you.
Best Regards,
Georgi
Hello Georgi,
thx a lot for your advice, value primitive should work. In addition, if my request could be taken as a future request, it would be great, seems just a few tweaks to the forms control could make it perfect & a little bit more manageable
Thx Alex
Hi, Alex,
We can certainly open a FR, however may I ask you to clarify a bit more about what the expected result is?
What should happen if you tell the form field.type = "string" when the default value in the formData is a number? Should it change the editor to a TextBox instead of NumericTextBox?
Best Regards,
Georgi
Hi, Alex,
I've synced with the Devs regarding this functionality and it looks like it is already possible to do what the schema.model of the dataSource does.
Take a look at the following example:
<form id="myForm"></form>
<script>
$("#myForm").kendoForm({
formData: {
ID: 1,
Date: kendo.toString(new Date(), "MM/dd/yyyy"), // String date
Number: "54" // String number
},
items: [{
field: "Date",
label: "Date:",
editor: "date", // Set the editor to "date" like you would do in a dataSource schema model.
validation: { required: true }
}, {
field: "Number",
label: "Number:",
editor: "number" // Set the editor to "number" like you would do in a dataSource schema model.
}]
});
</script>
Dojo
https://dojo.telerik.com/@gdenchev/ijOYeyeh
Let me know what you think.
Best Regards,
Georgi
Georgi,
this is exactly i have asked for, seems the documentation needs to be updated, here completely diff chose for editors
Defines the editor widget type. Available options are:
- DropDown widgets - "AutoComplete", "DropDownList", "ComboBox", "MultiSelect", "DropDownTree", "MultiColumnComboBox"
- DatePicker widgets - "DateInput", "DatePicker", "DateTimePicker", "TimePicker"
- Input widgets - "TextBox", "TextArea", "NumericTextBox", "MaskedTextBox", "RadioGroup", "CheckBoxGroup", "Switch", "Rating", "Slider", "ColorPicker", "ColorGradient", "ColorPalette", "FlatColorPicker", "Signature", "hidden"
- Editor widget - "Editor"
Hi, Aleksandr,
I am glad the problem has been resolved!
I'll add a note about updating the API example with additional information.
Best Regards,
Georgi