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

Kendo grid foreignkey column validation

2 Answers 284 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 21 Dec 2012, 06:38 AM
I unable to validate the dropdownlist if the user select "Please select" value when the update button is clicked

I have inline editing grid implementing foreign key column. In the foreignKey.cshtml i also add the option label ("Please select").



View in grid:
columns.ForeignKey(p => p.EmployeeID, (System.Collections.IEnumerable)ViewData["testStatus"], "EmployeeID", "EmployeeName");

//Model:
 [Required(ErrorMessage = "Required")]
 [DisplayName("Employee ")]
 [UIHint("GridForeignKey")]
 public int EmployeeID { get; set; }

//Shared/GridForeignKey.cshtml

@(
 Html.Kendo().DropDownList()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(""))
        .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
        .OptionLabel("Select value")

)

2 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 24 Dec 2012, 01:57 PM
Hello David,

It is working fine on my side - check the attached project.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
David
Top achievements
Rank 1
answered on 28 Dec 2012, 01:35 AM
Thanks Petur. 

It seems my GridForeignKey column is incorrect. I follow your sample and work perfectly
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
David
Top achievements
Rank 1
Share this question
or