This is a migrated thread and some comments may be shown as answers.

Validation Value Option label

11 Answers 420 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Gusev
Top achievements
Rank 1
Gusev asked on 27 Mar 2013, 08:02 AM
Hello!
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

Sort by
0
Georgi Krustev
Telerik team
answered on 27 Mar 2013, 01:11 PM
Hello Gusev,

 
I suppose that the DataValueField and DataTextField have the same value, which will cause the aforementioned case. Check this link for more information.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 28 Mar 2013, 11:34 AM
Hello!
I attach files!
I use 
[UIHint("WoodList")]
public virtual Wood Wood { get; set; }
Next:
@(Html.Kendo().DropDownList()
    .Name("Wood")
    .DataTextField("Description")
    .DataValueField("Id")
    .DataSource(databinding => databinding
        .Read(read => read
        .Action("SelectComboboxItems", "Wood")))
    .OptionLabel("Выберите древесину")
    .Value("")
)
And 
.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!
0
Georgi Krustev
Telerik team
answered on 29 Mar 2013, 04:00 PM
Hello Gusev,

 
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.

Greetings,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 02 Apr 2013, 07:28 AM
Hello!
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)
0
Vladimir Iliev
Telerik team
answered on 04 Apr 2013, 10:46 AM
Hi Gusev,

 
Please find the answers of your questions below:

  1. 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; }
  2. 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.
  3. 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).
  4.          
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 05 Apr 2013, 09:56 AM
Hello!
thanks for your answer!

1. I did this: (delete Required)
[UIHint("PlywoodList")]
[Display(Name = "Plywood Name")]
public virtual Plywood Plywood { get; set; }
and when I click button"add new object"  , then  I click Update (without selecting an element from DropDownList) and next I see this: ModelState invalid  + Json return this:  first.png
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 )
0
Vladimir Iliev
Telerik team
answered on 09 Apr 2013, 09:38 AM
Hi Gusev,

 
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.

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 10 Apr 2013, 10:07 AM
I have attached my project earlier
"Gusev : 02 Apr"
and at you it correctly  displays an error?

sorry for my bad english 
0
Vladimir Iliev
Telerik team
answered on 10 Apr 2013, 11:46 AM
Hi Gusev,

 
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.

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gusev
Top achievements
Rank 1
answered on 10 Apr 2013, 02:56 PM
Hello!
I do this:
http://www.kendoui.com/forums/mvc/dropdownlist/validation-value-option-label-(20mb).aspx
0
Vladimir Iliev
Telerik team
answered on 12 Apr 2013, 12:57 PM
Hi Gusev, 

 
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). 

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Gusev
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Gusev
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or