I have used Telerik-grid to list Pictures of Product.Product Pictures displayed successfully in telerik-grid.i have used edit and delete button for each picture in telerik-grid. Delete Operation works properly.But inline editing does not work.When i enter value in DisplayOrder field and try to Update record, Update operation does not performs.
_CreateOrUpdate.Pictures.cshtml
@using Telerik.Web.Mvc.UI;
<div>
@(Html.Telerik().Grid<ProductPictureModel>()
.Name("productpictures-grid")
.DataKeys(x =>
{
x.Add(y => y.Id).RouteKey("Id");
})
.Columns(columns =>
{
columns.Bound(x => x.PictureUrl)
.ClientTemplate("<a href='<#= PictureUrl #>' target='_blank'><img alt='<#= PictureId #>' src='<#= PictureUrl #>' width='150' /><a/>")
.ReadOnly();
columns.Bound(x => x.DisplayOrder);
columns.Command(commands =>
{
commands.Edit().Text(T("Admin.Common.Edit").Text);
commands.Delete().Text(T("Admin.Common.Delete").Text);
});
})
.Editable(x =>
{
x.Mode(GridEditMode.InLine);
})
.DataBinding(dataBinding =>
{
dataBinding.Ajax().Select("PictureList"Product", new { productId = Model.Id })
.Update("PictureUpdate", "Product")
.Delete("DeletePicture", "Product");
})
.EnableCustomBinding(true))
</div>
Update Method:
[GridAction(EnableCustomBinding = true)]
public ActionResult PictureUpdate(ProductPictureModel model, GridCommand command)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
return AccessDeniedView();
var productPicture = _productService.GetProductPictureById(model.Id);
if (productPicture == null)
throw new ArgumentException("No product picture found with the specified id");
//a vendor should have access only to his products
if (_workContext.CurrentVendor != null)
{
var product = _productService.GetProductById(productPicture.ProductId);
if (product != null && product.VendorId != _workContext.CurrentVendor.Id)
{
return Content("This is not your product");
}
}
productPicture.DisplayOrder = model.DisplayOrder;
_productService.UpdateProductPicture(productPicture);
return ProductPictureList(command, productPicture.ProductId);
}
What should i do to overcome this problem?
Thank you in advance