Hi,
I'm creating a master-detail grid (see the screenshot attached) and I need the following:
- Always show the first column in both grids as checkboxes. Currently in the master grid I need to click the column and after that a checkbox is shown so I need to click again to change the checkbox status. What I need is to show the checkbox always and when I click it only once I change it status.
- I need to do the details grid editable so I can check/uncheck the checkboxes in the first column. See the red circle in the screenshot, currently I can't see the checkbox. I did some trials with no success!
- When the user click the checkbox in the master grid then all checkboxes in the detailed grid for that row are set to checked (this is realized in the client side)
Both grids uses local data binding, once the controller returns the view I don't wanna access the server again to read the data of the grids. Here's my code
The view:
01.@(Html.Kendo().Grid(Model.ExpedienteRows)02. .Name("grid_SeleccionarPedidos")03. .Columns(columns =>04. {05. columns.Bound(c => c.IdExpediente).Hidden();06. columns.Bound(c => c.Seleccionado)07. .Width(90);08. columns.Bound(c => c.Autor).Width(190);09. columns.Bound(c => c.AnnoExpediente)10. .Title("Año")11. .Width(70);12. columns.Bound(c => c.NumeroExpediente)13. .Title("Número")14. .Width(120);15. })16. .Editable(ed => ed.Mode(GridEditMode.InCell))17. .HtmlAttributes(new { style = "height: 380px; with: 200px;" })18. .Scrollable(x => x.Height(300))19. .Sortable(x => x.SortMode(GridSortMode.MultipleColumn))20. .Filterable()21. .DataSource(dataSource => dataSource22. .Ajax()23. .ServerOperation(false)24. .Batch(true)25. .Model(model =>26. {27. model.Id(p => p.IdExpediente);28. })29. )30. .ClientDetailTemplateId("pedidos")31. .Events(e => e.DetailInit("detailInit"))32.)33. 34.<script id="pedidos" type="text/kendo-tmpl">35. @(Html.Kendo().Grid<PedidoRow>()36. .Name("gridPedido_#=IdExpediente#")37. .Columns(columns =>38. {39. columns.Bound(c => c.IdPedido).Hidden();40. columns.Bound(c => c.Seleccionado)41. .Width(40);42. columns.Bound(c => c.AnnoPedido).Width(70);43. columns.Bound(c => c.NumeroPedido).Width(70);44. columns.Bound(c => c.Proveedor).Width(70);45. columns.Bound(c => c.DescripcionMaterial).Width(70);46. columns.Bound(c => c.Importe)47. .Format("{0:N4}")48. .Width(70);49. })50. .HtmlAttributes(new { style = "with: 200px;" })51. .ToClientTemplate()52. )53.</script>54. 55.<script>56. function detailInit(e) {57. var grid = $("#gridPedido_" + e.data.IdExpediente).data("kendoGrid");58. grid.dataSource.data(e.data.Pedidos);59. }60.</script>and here's the model
01.public class SeleccionarPedidosModel02.{03. public IEnumerable<ExpedienteRow> ExpedienteRows { get; set; }04.}05. 06.public class ExpedienteRow07.{08. public bool Seleccionado { get; set; } // binded to the first column (checkbox)09. public Guid IdExpediente { get; set; }10. public string Autor { get; set; }11. public int NumeroExpediente { get; set; }12. public int AnnoExpediente { get; set; }13. public IEnumerable<PedidoRow> Pedidos { get; set; } // Detail grid content14.}15. 16.public class PedidoRow17.{18. public Guid IdPedido { get; set; }19. public bool Seleccionado { get; set; } // binded to the first column (checkbox)20. public int NumeroPedido { get; set; }21. public int AnnoPedido { get; set; }22. public string Proveedor { get; set; }23. public string DescripcionMaterial { get; set; }24. public decimal Importe { get; set; }25.}
Any help will be appreciated
Thanks.
