Hello.
I'm trying to add a button to upload an image in the grid. The problem is when the row is "saved". All elements of the file are stored, but the byte [] (picture) never reaches the controller.
He conseguido rellenar el grid mediante javascript
![]()
But when i try to save, the object received controller is empty in field img
![]()
I'm trying to add a button to upload an image in the grid. The problem is when the row is "saved". All elements of the file are stored, but the byte [] (picture) never reaches the controller.
He conseguido rellenar el grid mediante javascript
But when i try to save, the object received controller is empty in field img
@(Html.Kendo().Grid<InventarioMerlin.Models.ContadorModelo>() .Name("GridContadorModelo") .Columns(columns => { columns.Bound(p => p.id).Visible(false).Width(100); columns.Bound(p => p.nombre).Width(100); columns.Bound(p => p.isenabled).Width(100); columns.Bound(p => p.img).Width(100); columns.Command(c => c.Custom("Upload").Click("upload")).Title("Grafica").Width(100); columns.Bound(p => p.grafica).Width(100); columns.Command(command => { command.Edit(); }).Width(200); }) .ToolBar(toolbar => { toolbar.Create(); toolbar.Save(); }) .Editable(editable => editable.Mode(GridEditMode.InCell)) .Pageable(p => p.Refresh(true)) .Sortable() .Scrollable() .HtmlAttributes(new { style = "height:100%;" }) .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .Events(events => events .Error("error_handler") .RequestEnd("onRequestEnd")) .Model(model => { model.Field(p => p.img).Editable(true); model.Id(p => p.id); model.Field(p => p.id).Editable(false); model.Field(p => p.isenabled).DefaultValue(true); }) .Create(create => create.Action("ContadorModelo_Popup_Create", "Contador")) .Read(read => read.Action("ContadorModelo_Popup_Read", "Contador")) .Update(update => update.Action("ContadorModelo_Popup_Update", "Contador")) //.Destroy(update => update.Action("EditingPopup_Destroy", "Ccoconfiguraciones")) ) )function upload(e) { e.preventDefault(); rowSelected = this.dataItem($(e.currentTarget).closest("tr")); $('#myModal').modal({ show: true }) } $("#btnSaveChanges").click(function () { refreshGrid(); $('#myModal').modal('hide'); });function refreshGrid() { var grid = $("#GridContadorModelo").data("kendoGrid"); var dataSource = grid.dataSource; var data = dataSource.data(); $.each(data, function (index, rowItem) { if (rowItem.id == rowSelected.id) { rowItem.img = imageUploaded; rowSelected.dirty = true; } }); grid.refresh(); }