Validation Value Option label

12 posts, 0 answers
  1. Gusev
    Gusev avatar
    74 posts
    Member since:
    Dec 2012

    Posted 27 Mar 2013 Link to this post

    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!

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    2757 posts
    Member since:
    Sep 2012

    Posted 27 Mar 2013 Link to this post

    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!

  3. Gusev
    Gusev avatar
    74 posts
    Member since:
    Dec 2012

    Posted 28 Mar 2013 Link to this post

    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!

  4. Georgi Krustev
    Admin
    Georgi Krustev avatar
    2757 posts
    Member since:
    Sep 2012

    Posted 29 Mar 2013 Link to this post

    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!

  5. Gusev
    Gusev avatar
    74 posts
    Member since:
    Dec 2012

    Posted 02 Apr 2013 Link to this post

    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)

  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    1320 posts
    Member since:
    Aug 2012

    Posted 04 Apr 2013 Link to this post

    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!

  7. Gusev
    Gusev avatar
    74 posts
    Member since:
    Dec 2012

    Posted 05 Apr 2013 Link to this post

    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 )

  8. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    1320 posts
    Member since:
    Aug 2012

    Posted 09 Apr 2013 Link to this post

    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!

  9. Gusev
    Gusev avatar
    74 posts
    Member since:
    Dec 2012

    Posted 10 Apr 2013 Link to this post

    I have attached my project earlier
    "Gusev : 02 Apr"
    and at you it correctly  displays an error?

    sorry for my bad english 

  10. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    1320 posts
    Member since:
    Aug 2012

    Posted 10 Apr 2013 Link to this post

    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!

  11. Gusev
    Gusev avatar
    74 posts
    Member since:
    Dec 2012

    Posted 10 Apr 2013 Link to this post

    Hello!
    I do this:
    http://www.kendoui.com/forums/mvc/dropdownlist/validation-value-option-label-(20mb).aspx

  12. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    1320 posts
    Member since:
    Aug 2012

    Posted 12 Apr 2013 Link to this post

    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!

Back to Top