Hi,
I have a dropdownlist defined as follows:
<input class="input-width-75"
data-role="dropdownlist" data-auto-bind="false" name="signature" data-option-label="select signature" data-value-primitive="true"
data-text-field="name" data-value-field="name" data-bind="source: signatureDatasource, value: signature" required/>
After running the .validate() function, tooltip not showing saying that this is required! The required attribute is showing on the "hidden" input though in HTML.
Any idea?
I have a dropdownlist defined as follows:
<input class="input-width-75"
data-role="dropdownlist" data-auto-bind="false" name="signature" data-option-label="select signature" data-value-primitive="true"
data-text-field="name" data-value-field="name" data-bind="source: signatureDatasource, value: signature" required/>
After running the .validate() function, tooltip not showing saying that this is required! The required attribute is showing on the "hidden" input though in HTML.
Any idea?
4 Answers, 1 is accepted
0
Bilal
Top achievements
Rank 2
answered on 25 Feb 2015, 02:41 PM
I did a small change by making data-text-field and data-value-field different, it works and I can see the Required message beside the dropdownlist.
When both are equal, this means, the data-option-label record will have both the data-text-field and data-value-field same value as data-option-label, however, then they are different, data-option-label record will have data-value-field empty or null, correct? That's the only explanation I could come up with.
How can I make it work while having both data-text-field and data-value-field the same data field?
Thanks
When both are equal, this means, the data-option-label record will have both the data-text-field and data-value-field same value as data-option-label, however, then they are different, data-option-label record will have data-value-field empty or null, correct? That's the only explanation I could come up with.
How can I make it work while having both data-text-field and data-value-field the same data field?
Thanks
0
Bilal
Top achievements
Rank 2
answered on 25 Feb 2015, 03:20 PM
I did a small change on the above DropDownList. I made sure data-text-field and data-value-field are different, then it works.
The only reasoning I could think of is as follows:
- data-text-field and data-value-field refer to the same data field
- data-value-primitive = "true"
- data-option-label is set, means, data-text-field and data-value-field for the "data-option-label" are the same both are "select signature"
Therefore, the value of first item selected (data-option-label) have both text and value field to be "select signature".
If the data-text-field and data-value-field are to be different, something as "name" and "signatureId" and data-value-primitive = "false", then, data-option-label will have for text field "select signature" and for value field empty. That's why, having text and value field different + data-primitive-value = "false" makes the validation work.
Is there any other explanation?
Thanks
The only reasoning I could think of is as follows:
- data-text-field and data-value-field refer to the same data field
- data-value-primitive = "true"
- data-option-label is set, means, data-text-field and data-value-field for the "data-option-label" are the same both are "select signature"
Therefore, the value of first item selected (data-option-label) have both text and value field to be "select signature".
If the data-text-field and data-value-field are to be different, something as "name" and "signatureId" and data-value-primitive = "false", then, data-option-label will have for text field "select signature" and for value field empty. That's why, having text and value field different + data-primitive-value = "false" makes the validation work.
Is there any other explanation?
Thanks
0
Hello Bilal,
Your observations are correct. The DropDownList creates a fake object (optionLabel) based on the dataTextField and dataValueField options. If both options are equal, then the optionLabel text will become a value. This is the as defining a SELECT element with options that does not have specific value attribute:
The value of the first option will be the text. This exactly happens in DropDownList widget.
If you would like to use optionLabel functionality, then you will need to use more complex objects or you will need to check whether the selected value is the optionLabel text and perform your specific business requirements.
The valuePrimitive option is not related to this functionality.
Regards,
Georgi Krustev
Telerik
Your observations are correct. The DropDownList creates a fake object (optionLabel) based on the dataTextField and dataValueField options. If both options are equal, then the optionLabel text will become a value. This is the as defining a SELECT element with options that does not have specific value attribute:
<
select
>
<
option
>Please select...</
option
>
<
option
>Item1</
option
>
<
option
>Item2</
option
>
</
select
>
If you would like to use optionLabel functionality, then you will need to use more complex objects or you will need to check whether the selected value is the optionLabel text and perform your specific business requirements.
The valuePrimitive option is not related to this functionality.
Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bilal
Top achievements
Rank 2
answered on 27 Feb 2015, 11:28 AM
Hello Georgi,
Thanks a lot. As i mentioned, I solved it by using an object for the value selected, and hence it works now.
Best regards
Bilal Haidar
Thanks a lot. As i mentioned, I solved it by using an object for the value selected, and hence it works now.
Best regards
Bilal Haidar