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

Refreshing edited row after pressing update when using Inline Edit

1 Answer 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 16 May 2014, 11:19 AM
I'm working on an application which I have now almost finished but I have one thing that I really need to sort out before I release. I return a dataset of around 600 rows to the grid. I then chose to Edit one of these rows and change the value in a ComboBox Editor template. For example, I might change it from Jan Jones to John Smith.

This all works fine at the database level. However, when I press Update the values displayed in the Display template are still Jan Jones and not John Smith. So far, the only way I've been able to get this to work is by using a dataSource refresh in the onSync event. However, this is taking at least 15 seconds to reload the entire grid.I guess it is returning the entire dataset and not just the currently displayed page.  

Presumably, I am doing something wrong somewhere but I am not sure where. Any help would be most useful as I have been scratching my head on this for a while now.

Controller
01.public JsonResult GetTestDetailed([DataSourceRequest] DataSourceRequest request)
02.{
03.                var testTable = dataAccessLayer.GetDataTable("select statement here");
                          //testTable will be about 600 rows
04.                var testDictionary = (from DataRow row in testTable.Rows select testTable.Columns.Cast<DataColumn>  ().ToDictionary(column => column.ColumnName, column => row[column].ToString())).ToList().AsQueryable();
05.                return Json(testDictionary.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
06.            }
07.        }
08.         
09.    [AcceptVerbs(HttpVerbs.Post)]
10.        public ActionResult Update([DataSourceRequest] DataSourceRequest request, TestDirectoryDetail testDetail)
11.        {
12.        dataAccessLayer.Update(testDetail);
13.            return Json(new[] { testDetail }.ToDataSourceResult(request, ModelState));
14.        }


Grid

01.<script type="text/javascript">
02.    function onSync(e) {
03.        var grid = $('#TestGrid').data('kendoGrid');
04.        grid.dataSource.read();
05.    }
06.</script>
07. 
08.@(Html.Kendo().Grid((IEnumerable<DirectoryDetail>)ViewBag.Details)
09.    .Name("TestGrid")
10.     .HtmlAttributes(new { style = "height:850px;" })
11.    .Editable(editable => editable.Mode(GridEditMode.InLine))
12.    .Events(e => e.SaveChanges("onSaveChanges"))
13.    .Filterable()
14.    .Groupable()   
15.    .Pageable() // Enable pageing
16.    .Scrollable(scr=>scr.Height("auto"))
17.    .Sortable() // Enable sorting
18.    .DataSource(dataSource => dataSource
19.            .Ajax()
20.            .Events(events => events.Error("error_handler").Sync("onSync"))
21.            .PageSize(15)
22.            .Model(model =>
23.            {
24.                model.Id(p => p.Id);
25.            })
26.            .Update(update => update.Action("Update", "Home"))
27.            .Read(read => read.Action("GetPracticesDetailed", "Home"))
28.        )
29.    .Columns(columns =>
30.    {
31.        columns.Bound(m => m.PracticeId).Title("Id");
32.        columns.Bound(m => m.PayManager).Width(150).Title("DPM").Template(m => m.PayManager).EditorTemplateName("PayManagerDropDown").ClientTemplate("#:PayManager#");
33.        columns.Command(command => command.Edit()).Title("Actions");
34.    })           
35.    .Resizable(resize => resize.Columns(true)))

Dropdown
01.@(Html.Kendo().ComboBox()
02.        .Name("PayManagerId")
03.        .Filter(FilterType.StartsWith)
04.        .HtmlAttributes(new {style = "width:auto;"})
05.        .Placeholder("Type beginning of name to select new pay manager")
06.        .DataTextField("FullName")
07.        .DataValueField("userid")
08.        .AutoBind(true)
09.        .Suggest(true)
10.        .DataSource(source => source.Read(read => read.Action("GetUsers", "Home")).ServerFiltering(false)))


1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 20 May 2014, 06:38 AM
Hi Alex,

From the snippets you have pasted it is not obvious if the PayManager (I guess this is a string field with the name of the manager) field is updated. Looking at the code the custom editor is bound to the PayManagerId which will be updated when the ComboBox value is changed. However, you should make sure that the PayManager field is updated correctly with the new value when the record is updated on the server.

If you continue to experiencing difficulties please provide us with a small runnable sample in which this issue can be observed locally. 

Regards,
Rosen
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or