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

Having trouble performing actions on a class with properties that are classes using Grid

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kerry
Top achievements
Rank 1
Kerry asked on 05 Oct 2012, 07:40 PM

I have a simple class that has a class as one of it's properties.  I am trying to use the grid to both display the properties and allow in-line editing.  If I don't use default values and I try to edit I get "Microsoft JScript runtime error: Syntax error, unrecognized expression: [data-container-for=Person.PersonId].

If I do use default values I get "Cannot serialize objects of type Person" when I load the page.

Help would be greatly appreciated since I haven't been able to find any information.

-Kerry

Here's the code

class User
{
    int UserId;
    string LoginName;
    Person person;
}

class Person
{
    int PersonId;
    string FirstName;
    string LastName;
    string Email;
}

 

<%

 

= Html.Kendo().Grid<UserDto>()

 

.Name("UserListGrid")

.DataSource(ds => ds.Ajax()

.Update(update => update.Action("AjaxSaveUser", "User"))

.Destroy(destroy => destroy.Action("AjaxDeleteUser", "User"))

.Create(create => create.Action("AjaxInsertUser", "User"))

.Read(read => read.Action("List", "User"))

.Model(model => model.Id(m => m.UserId))

.Model(model => model.Field(m => m.UserId).Editable(false))

.Events(e => e.Error("grid_OnError"))

)

.Columns(col =>

{

col.Bound(us => us.UserId).Title("ID");

col.Command(us => us.Edit());

col.Bound(us => us.LoginName).Title("Login");

col.Bound(us => us.Person.PersonId).Hidden();

col.Bound(us => us.Person.LastName).Title("Last Name");

col.Bound(us => us.Person.FirstName).Title("First Name");

col.Bound(us => us.Person.Email).Title("Email");

col.Command(us => us.Destroy());

})

.ToolBar(commands => commands.Create().Text("Add User"))

.Editable(edit => edit.Mode(GridEditMode.InLine))

%>

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 10 Oct 2012, 04:45 PM
Hi Kerry,

I am afraid that what you would like to achieve is not supported out of the box, because the DataSource does not support hierarchical (nested) data structures. If you want to use the editing functionality the only solution is to use a flat data structure.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Kerry
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or