I have DropDownList with OptionLabel
If I create new data, first element in my DropDownList , it's text from OptionLabel
And I push SaveButton! But I don't get error : "you have not chosen 'here name of field'"!
what am I doing wrong?
Thanks for help!
11 Answers, 1 is accepted
I suppose that the DataValueField and DataTextField have the same value, which will cause the aforementioned case. Check this link for more information.
Georgi Krustev
the Telerik team
I attach files!
I use
[UIHint("WoodList")]
public virtual Wood Wood { get; set; }@(Html.Kendo().DropDownList()
.Name("Wood")
.DataTextField("Description")
.DataValueField("Id")
.DataSource(databinding => databinding
.Read(read => read
.Action("SelectComboboxItems", "Wood")))
.OptionLabel("Выберите древесину")
.Value("")
)
.Model(model => {
model.Id(p => p.Id);
model.Field(p => p.Wood).DefaultValue(new Wood());
})
And if I use button CREATE, I see data from "please see first picture"
If I click on any items and next again click on optionLabel I see "please see second picture"
Model Wood:(first picture)
Id : 0 and i.e. ...because I use DefaultValue
and Next:(second picture)
Model Wood: null
maybe that's why my validation is broken?
maybe not )
please help!
Thank you for the code snippets. I believe that the DropDownList widget is bound to the Wood property. Hence when optionLabel is clicked its value Wood property is set to null. It will be great if you can send us a simple test project, which replicates the issue. Thus we will be able to examine it locally and advice you further.
Georgi Krustev
the Telerik team
I attach my project!
I don't attach packages
(In dbConfiguration...I set hard path(please change him))
I have objects: Press,Plywood,PressPlywood (Pmasc.Mes.PlywoodMillWeb.Business\Entities\Catalogues)
"View Press" has EditorTemplates
Object Plywood has attribute Uihint["PlywoodList"] for Combobox
PlywoodList and Press are in Views\Catalogues\EditorTemplates
1) If I create new object(New PressPlywood in editablePopUpWindow from Press) and I choose optionLabel , I don't see error: "Required field "PressPlywood" "
2) If I use "Aggregates" in Press.cshtml (f.e. - aggregates => aggregates.Press).Count())
And next I Create new object.....column's info(elements count "Press" ) doesn't refresh...
3) And please answer me, why my tag <input> for editable field "string" has class ="textbox", but not "k-textbox"
Sorry, that I write all errors in this post) and for my bad English)
Please help! And thanks)
Please find the answers of your questions below:
- Basically the OptionLabel changes DropDownList value to null. After reviewing the provided project it seems that current behavior is expected with the current logic - the "Plywood" property have "Required" attribute which is the reason for this validation. I would suggest to remove the "Required" attribute in current scenario.
//[Required] - > this attribute restricts choosing the OptionLabel (null value)
[UIHint(
"PlywoodList"
)]
[Display(Name =
"Наименование фанеры"
)]
public
virtual
Plywood Plywood {
get
;
set
; }
- Your second question is not related to the original topic of this support conversation, so please submit a new support ticket for it. In this way you can be sure that your query will reach the corresponding staff member in time and will be answered faster and accurately.
- This is the default editor for "string" type in MVC - I would suggest to create new EditorTemplate (under the Views -> Shared -> EditorTemplates) with name "string" in which you can define custom editor for string type with custom HTML attributes (in current case add custom class).
Vladimir Iliev
the Telerik team
thanks for your answer!
1. I did this: (delete Required)
[UIHint("PlywoodList")]
[Display(Name = "Plywood Name")]
public virtual Plywood Plywood { get; set; }
In Controller: second.png
How I can do ClientValidation in this example?
I don't want go to Controller, when I don't selecting an element from DropDownList? I want show Error :)
2. ok)
3. thanks )
From the provided information it's not clear for us what is the exact reason for this behavior - I would suggest to open a new support ticket and provide runnable project (with all packages) where the issue is reproduced. This would help us pinpoint the exact reason for this behavior.
Vladimir Iliev
the Telerik team
"Gusev : 02 Apr"
and at you it correctly displays an error?
sorry for my bad english
The previously provided project have too many missing dependencies - in the version that we able to run it on our side after removing the "required" attribute the project works as expected. I would suggest to open a new support thread (where you can attach files up to 20mb) and provide runable project where the issue is reproduced.
Vladimir Iliev
the Telerik team
I do this:
http://www.kendoui.com/forums/mvc/dropdownlist/validation-value-option-label-(20mb).aspx
After reviewing the provided project it seems that the issue is not directly related to KendoUI Grid but to the current data access layer that is used - the grid is sending correctly the updated record data and allows selecting of null values (OptionLabel).
Vladimir Iliev
the Telerik team