带有图像的删除按钮

Delete Button with image

我在 DevExpress 中为 MVC 使用 GridView 实现了一个演示。

我想在我的 GridViewPartial 视图中为删除按钮设置一个图像。

有人知道怎么设置吗?

@{
var grid = Html.DevExpress().GridView(settings => {
...
settings.CommandColumn.Visible = true;
settings.CommandColumn.ShowNewButton = true;
settings.CommandColumn.ShowEditButton = true;
...
            });
    if (ViewData["EditError"] != null){
    grid.SetEditErrorText((string)ViewData["EditError"]);
}
}

@grid.Bind(Model).GetHtml()

谢谢朋友们。

已编辑: 试试这个

settings.SettingsCommandButton.DeleteButton.ButtonType = GridCommandButtonSettings.Image;
settings.SettingsCommandButton.DeleteButton.Image.Url = "~/content/images/icons/icon_delete.png";

它returns"Is needed a reference, method or property non statics "DevExpress.Web.GridCommandButtonSettings.Image.get""

做到了,

在 Razor 视图中(可能您正在使用 GridViewPartial)通过以下方式定义按钮:

settings.SettingsCommandButton.DeleteButton.ButtonType = GridCommandButtonRenderMode.Image;
settings.SettingsCommandButton.DeleteButton.Image.Url = "~/Content/Images/next.png";

对较新版本的 DevExpress 进行了轻微更新。 ButtonType deprecated 支持呈现模式。

新建

settings.SettingsCommandButton.RenderMode = GridCommandButtonRenderMode.Image; 
settings.SettingsCommandButton.DeleteButton.Image.Url = "~/Content/Images/next.png";

已过时

settings.SettingsCommandButton.DeleteButton.ButtonType = GridCommandButtonRenderMode.Image;