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

Binding Create action, null model

1 Answer 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 18 Sep 2012, 11:59 AM
Hello I am tryint to bind create action from Kendo Grid:

@(Html.Kendo().Grid<CPSkla.Models.GlobalProperties>().Name("GlobalProperties")
    .Columns(columns =>
    {
        columns.Bound(p => p.Id).Hidden();
        columns.Bound(p => p.Name);
        columns.Bound(p => p.Value);
        columns.Command(command => command.Destroy());
    })
    .DataSource(dataSource => dataSource.Ajax().Batch(true)
        .Model(model =>  model.Id(p => p.Id))
        .Create("GlobalProperty_Create", "Admin")       
        .Read("GlobalProperty_Read", "Admin")
        .Update("GlobalProperty_Editing_Update", "Admin")
        .Destroy("GlobalProperty_Editing_Destroy", "Admin")
    )
    .ToolBar(toolbar =>
    {
        toolbar.Create();
        toolbar.Save();
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
)


This is supposed to send Create action to my Admin controller (this works)

public ActionResult GlobalProperty_Create(List<GlobalProperties> models)
       {
           using (var db = new CPSkla.Models.CPSklaEntitiesCalculation())
           {
               foreach (GlobalProperties model in models)
               {
                   db.GlobalProperties.Add(model);
                   db.SaveChanges();
               }
           }
           return View(GetViewResult());
       }

Now if I try to create ne record it will trigger my breakpoint in controller but the list (although it has Count=1 for one new record) has GlobalProperty object but with all values (Id,Name,Value) null.

My firebug shows that I have
models[0][id]  0
models[0][name] test
models[0][value] testssss
as a part of my parametres, how do I serialize that to my List?

Please help I was trying to find it but without success.

This thread is copy of http://www.kendoui.com/forums/ui/grid/binding-create-action-null-model.aspx

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 21 Sep 2012, 07:37 AM
Hi David,

Share a small project which reproduces the behavior and we will be glad to take a look and see what goes wrong.

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!
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or