I'm using the Kendo Grid with a Microsoft MVC app, but I don't have the UI for MVC component due to the license we purchased. We will fix that next year when we renew, but right now I'm just using plain JavaScript.
My datasource is a list of objects from Entity Framework, which includes a Reference field called "PersonType". When creating new records, I'm having trouble because ModelState.IsValid == false because the reference object IS being created by the MVC binding, but all of it's properties are NULL and some of those values are required. If the MVC binding didn't create the PersonType object at all there then the ModelState would be valid, because the reference object itself isn't required. I can see that the grid is passing the reference value as null, but having the property passed caused the binding to create the null object. I was trying to use the parameterMap to remove these fields, but can't get the syntax correct.
The classes look like this:
public class PersonType
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
[Required, StringLength(5)]
public string PersonTypeId { get; set; }
[Required, StringLength(100)]
public string PersonTypeName { get; set; }
}
public class Person
{
public int PersonId { get; set; }
public string PersonTypeId { get; set; }
public PersonType PersonType { get; set; }
}
It's the PersonType reference field in the Person object that is giving me trouble (PersonTypeId is working correctly). How can I remove the PersonType reference when the grid posts the create, or what's the best way to handle the reference fields with the Kendo Grid?