Hi support,
I need to create a Parent/Child grid and both grids must be editable. I've seen some examples in the forum and non of them fit my scenario.
In my case both grids uses local data binding so there's no need for .Create() .Read() .Update() .Destroy() methods in the datasource. One action return the view with the data needed to show in both grids.
The problem I'm facing is that when I add .Editable(ed => ed.Mode(GridEditMode.InCell)) to the child grid without specifying a datasource I get this error:
An exception of type 'System.NotSupportedException' occurred in Kendo.Mvc.dll but was not handled in user code
Additional information: There is no DataSource Model Id property specified.
Now if I add a datasource like the one below nothing is shown in the child grid but the header.
01..DataSource(dataSource => dataSource02. .Ajax()03. .ServerOperation(false)04. .Batch(true)05. .Model(model =>06. {07. model.Id(p => p.ID);08. })09.)
I also checked these demos
http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/edit-master-row-data-in-detail-template
http://www.telerik.com/support/code-library/grid-ajax-hierarchy-editing
but both use a datasource with .Create() .Read() .Update() .Destroy() operations in the child grid so they're useless to me.
Is it possible to create the child grid editable without CRUD operations in its datasource?
Any help will be appreciated.
PS: I don't even need the Read operation in the datasource because I already have these data!
Here's my code
View:
01.@using TelerikTests.Models02.@model TestModel03. 04.@{05. ViewBag.Title = "Home Page";06.}07. 08.@(Html.Kendo().Grid(Model.Categories)09. .Name("grid_Parent")10. .Columns(columns =>11. {12. columns.Bound(c => c.ID).Hidden();13. columns.Bound(c => c.Description)14. .Width(50);15. columns.Bound(c => c.DateCategory)16. .Format("{0:yyyy/MM/dd}")17. .Width(100);18. })19. .HtmlAttributes(new { style = "height: 380px;" })20. .Scrollable(x => x.Height(300))21. .Sortable(x => x.SortMode(GridSortMode.MultipleColumn))22. .Filterable()23. .DataSource(dataSource => dataSource24. .Ajax()25. .ServerOperation(false)26. .Batch(true)27. .Model(model =>28. {29. model.Id(p => p.ID);30. })31. )32. .ClientDetailTemplateId("child")33. .Events(e => e.DetailInit("childGridInit"))34.)35. 36.<script id="child" type="text/kendo-tmpl">37. @(Html.Kendo().Grid<ProductModel>()38. .Name("gridChild_#=ID#")39. .Columns(columns =>40. {41. columns.Bound(c => c.ID).Hidden();42. columns.Bound(c => c.Name)43. .Width(70);44. columns.Bound(c => c.Price)45. .Width(70);46. })47. //.Editable(x => x.Mode(GridEditMode.InLine))48. //.DataSource(dataSource => dataSource49. // .Ajax()50. // .ServerOperation(false)51. // .Batch(true)52. // .Model(model =>53. // {54. // model.Id(p => p.ID);55. // })56. //)57. .ToClientTemplate()58. )59.</script>60. 61.<script>62. function childGridInit(e) {63. var grid = $("#gridChild_" + e.data.ID).data("kendoGrid");64. grid.dataSource.data(e.data.Products);65. }66.</script>
The model:
01.public class TestModel02.{03. public IEnumerable<CategoryModel> Categories { get; set; }04.}05. 06.public class CategoryModel07.{08. public Guid ID { get; set; }09. public string Description { get; set; }10. public DateTime DateCategory { get; set; }11. public IEnumerable<ProductModel> Products { get; set; }12.}13. 14.public class ProductModel15.{16. public Guid ID { get; set; }17. public DateTime DateProduct { get; set; }18. public string Name { get; set; }19. public decimal Price { get; set; }20.}