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

graphic issue on create transport

2 Answers 11 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gaetano
Top achievements
Rank 1
Gaetano asked on 19 Feb 2014, 01:58 PM
Hi guys,
I'm working with a kendo mvc grid
here it is

@(Html.Kendo().Grid<Entity>(Model)
        .Name("valueGrid")
        .ToolBar(commands => commands.Create())
        .Columns(columns =>
        {
            columns.Bound(c => c.DOMAINID);
            columns.Bound(c => c.CODE);
            columns.Bound(c => c.VALUE);
            columns.Command(command => { command.Edit(); command.Destroy(); });
        })
        .Sortable()
        .Scrollable()
        .DataSource(dataSource => dataSource       
        .Ajax()
        .ServerOperation(false)      
        .Model(m => m.Id(v => v.DOMAINID))
        .Update(update => update.Action("UpdateValue", "DomainValue"))
        .Create(create => create.Action("CreateValue", "DomainValue"))
        .Destroy(delete => delete.Action("DeleteValue", "DomainValue"))
     )
    )


and that's my controller

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult CreateValue([DataSourceRequest] DataSourceRequest request, Value domValue)
{
    if (ModelState.IsValid)
    {
        db.Values.Add(domValue);
        db.SaveChanges();
    }
    DataSourceResult result = db.Values.Where(v => v.DOMAINID == domValue.DOMAINID).ToDataSourceResult(request, ModelState);
    return Json(result);
}

The whole operation works fine, the only issue is that the grid display wrong values...

ex

grid with values (id: 5, name: test, value: test)

if I add a new object (6, trial, trial); the new object is correctly added to the database but the new object appears with the same values as the first one in grid (in this case with 5, test, test...

I attached 2 screenshots to better explain my issue.

Thanks
Fabio

2 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 21 Feb 2014, 11:26 AM
Hi Fabio,

Basically the ID (in this case DOMAINID) should be unique, otherwise this behavior could be observed. I would recommend using a non-editable field for the Model's ID and assign it some unique value on the server-side.

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Gaetano
Top achievements
Rank 1
answered on 25 Feb 2014, 09:40 AM
Hi Alexander,
I changed my Model ID from DOMAINID to CODE and nothing changed.
But looking at my controller I noticed that I serialized back a list of object (containing the new one).
I tried to return just the newly created object and now it all works fine.
Thanks
Fabio




Tags
Grid
Asked by
Gaetano
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Gaetano
Top achievements
Rank 1
Share this question
or