Binding Grid with Model having Non nullable properties creating issue.

5 posts, 0 answers
  1. Prashanth
    Prashanth avatar
    2 posts
    Member since:
    Dec 2012

    Posted 11 Dec 2012 Link to this post

    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.
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2196 posts

    Posted 13 Dec 2012 Link to this post

    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!
  3. Prashanth
    Prashanth avatar
    2 posts
    Member since:
    Dec 2012

    Posted 17 Dec 2012 Link to this post

    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.

  4. license
    license avatar
    2 posts
    Member since:
    Nov 2010

    Posted 17 Dec 2012 Link to this post

    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.
  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2196 posts

    Posted 19 Dec 2012 Link to this post

    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!
Back to Top