我正在尝试为剑道网格中的产品上传图片(内联编辑)。在插入它工作正常。在更新中,它不允许我只更改图像。单击更新按钮后,除非我更改其他字段之一,否则它不会进入控制器。
因此,如果有办法强制更新按钮转到控制器,那将会很有帮助。
@(Html.Kendo().Grid(Model)
.Name("BrandGrid")
.Events(e => e.Edit("edit").DataBound("onDataBound").Cancel("onDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(true)
.Events(events => events.Error("error_handler"))
.PageSize(10)
.Model( model =>{
model.Id(p => p.BrandID);
model.Field(p => p.BrandID).Editable(false);
})
.Update(update => update.Action("Brand_Update", "Brands"))
.Create(insert => insert.Action("Brand_Insert", "Brands"))
.Read(read => read.Action("Brand_Read", "Brands"))
.Destroy(delete => delete.Action("Brand_Delete", "Brands"))
)
.Columns(columns =>
{
columns.Bound(p => p.BrandID).Groupable(false).Title(MyResources.LabelBrandID).HeaderHtmlAttributes(new { style = "text-align:" + MyResources.HeaderDirection });
columns.Bound(p => p.BrandNameE).Title(MyResources.LabelBrandNameE).HeaderHtmlAttributes(new { style = "text-align:" + MyResources.HeaderDirection });
columns.Bound(p => p.BrandNameA).Title(MyResources.LabelBrandNameA).HeaderHtmlAttributes(new { style = "text-align:" + MyResources.HeaderDirection });
columns.Bound(p => p.BrandID).Width(120).Title(" ").Filterable(false)
.ClientTemplate(@"<img alt='Brand Image' src='" + Url.Content("~/Images/Brands/") + "#=data.BrandID#.jpg' alt=\"${data.BrandID}\" />");
columns.Template(@<text></text>).Title(" ").ClientTemplate("<input type=file name='files' onchange='dataBound(this.value)' />").Width(280).Hidden(true);
columns.Command(command => { command.Edit().Text(MyResources.EditText).CancelText(MyResources.CancelText).UpdateText(MyResources.UpdateText); command.Destroy().Text(MyResources.Delete); });
})
.ToolBar(toolbar => toolbar.Create().Text(MyResources.AddNewItem))
.Pageable(pager => pager
.Numeric(true)
.PreviousNext(true)
.Refresh(true)
.PageSizes(true)
)
.Filterable(filterable => filterable
.Extra(true)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith(MyResources.StartsWith)
.IsEqualTo(MyResources.IsEqualTo)
.IsNotEqualTo(MyResources.IsNotEqualTo)
.Contains(MyResources.Contains)
.DoesNotContain(MyResources.DoesNotContain)
.EndsWith(MyResources.EndsWith)
)
.ForNumber(num => num.IsEqualTo(MyResources.IsEqualTo).IsGreaterThan(MyResources.IsGreaterThan).IsNotEqualTo(MyResources.IsNotEqualTo).IsGreaterThanOrEqualTo(MyResources.IsGreaterThanOrEqualto).IsLessThanOrEqualTo(MyResources.IsLessThanOrEqualTo).IsLessThan(MyResources.IsLessThan))
)
.Messages(messages => messages.Info(MyResources.Info).Filter(MyResources.Filter).Clear(MyResources.Clear).And(MyResources.And).Or(MyResources.Or))
)
.Pageable(pager => pager.Messages(messages => messages.Display(MyResources.Display).Empty(MyResources.Empty).First(MyResources.GoToTheFirstPage).Last(MyResources.GoToTheLastPage).Next(MyResources.GoToTheNextPage).Previous(MyResources.GoToThePreviousPage).Of(MyResources.of).Page(MyResources.page).ItemsPerPage(MyResources.ItemsPerPage).Refresh(MyResources.Refresh)))
.Selectable(selectable => selectable
.Mode(GridSelectionMode.Multiple))
.Navigatable()
.Sortable()
.Scrollable(scr => scr.Height(405))
.Resizable(resize => resize.Columns(true))
//.HtmlAttributes(new { style = "height:430px;" })
.Editable(editablee => editablee.Mode(GridEditMode.InLine).DisplayDeleteConfirmation(MyResources.DeleteConfirmMessage))
)