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

Binding Grid with Model having Non nullable properties creating issue.

4 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prashanth
Top achievements
Rank 1
Prashanth asked on 11 Dec 2012, 01:38 PM
Hi

I have upgraded my kendo application from 2012.2.710  to 2012.3.1114. In the updated dll, when i do ajax binding , the non nullable properties of the model is throwing error but the same was working fine in the '2012.2.710' version. What went wrong in the new version ? please give me a proper solution for this issue. The code to bind the grid is given below.

@(Html.Kendo().Grid<LinklistRow>()
        .Name("Grid").Selectable()
                     .ToolBar(commands => commands.Create().HtmlAttributes(new { Title = "Add New Link" }))                
                .Columns(columns =>
                {
                    columns.Bound(client => client.lkLinkId).Hidden();
                    columns.Bound(client => client.lkTitle).Title("Title").Width(200).Sortable(true);
                    columns.Bound(client => client.lkUrl).Title("Url").Width(500).Sortable(true);
                    columns.Command(commands =>
                    {
                        commands.Edit().Text(" ").UpdateText(" ").CancelText(" ").HtmlAttributes(new { Title = "Edit" });
                        commands.Destroy().Text(" ").HtmlAttributes(new { Title = "Delete" }); ;
                    }).Width(90).HtmlAttributes(new { @class = "k-gridButtonAlignment" });
                }).Editable(editable => editable.Mode(GridEditMode.InLine))
                .Events(e => e.Edit("OnEdit"))
                    .DataSource(dataSource => dataSource.Ajax()
                    .ServerOperation(false)                        
                    .Read(read => read.Action("Show", "Home", new { area = "Link", clientId = Model.ClientId }))
                    .Model(model => model.Id(c => c.lkLinkId))
                    .Create("Create", "Home", new { area = "Link", clientId = Model.ClientId })
                    .Update("Edit", "Home", new { area = "Link", clientId = Model.ClientId })
                            .Destroy("Destroy", "Home", new { area = "Link", clientId = Model.ClientId })
                            .PageSize(20)
                            ).Pageable(pager => pager.PageSizes(true)).Sortable()
                    )

Thanks
Prashanth.

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 13 Dec 2012, 10:20 AM
Hi Prashanth,

I tried to reproduce the problem locally with the provided code but to no avail – everything is working as expected on our side. Please provide run-able project where the issue is reproduced – hopefully this will 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!
0
Prashanth
Top achievements
Rank 1
answered on 17 Dec 2012, 12:58 PM
Hi ,

I have attached the sample project. Create a 'Test' db and execute the sql in 'KendoTest\Models' folder. This is a query to create a table, after table creation ,manually enter some data into it,  make the respective modifications in edmx files's connection string to connect with the Test db.Execute the project, then you will find this issue of non nullable fields showing error while binding. I think you have only checked with the read functionality , please check it with Create, update and destroy. Please check it and send us a solution for this issue.

Thanks
Prashanth.

0
license
Top achievements
Rank 1
answered on 17 Dec 2012, 01:33 PM
I'm not sure is your problem like mine but I manage to escape from the error

     .DataSource(dataSource => dataSource
            .Ajax()
                .Model(m =>
                {
                    m.Id(p => p.Id));
                    m.Field(f => f.FirstName).DefaultValue(string.Empty);
                    m.Field(f => f.LastName).DefaultValue(string.Empty);
 
                })
)
I just set DefaultValue(string.Empty)

P.S Its interesting that now with the latest version of Kendo I also could not reproduce
that error.
0
Vladimir Iliev
Telerik team
answered on 19 Dec 2012, 08:45 AM
Hi Prashanth,

 
After reviewing the provided project it seems that you are trying to bind the Grid directly to the generated complex object by EntityFramework - the error is thrown because the Grid  tries to serialize it and access all properties of the model. Basically you should create View Model and bind the Grid to it.


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!
Tags
Grid
Asked by
Prashanth
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Prashanth
Top achievements
Rank 1
license
Top achievements
Rank 1
Share this question
or