我正在尝试向我的 mvc 网格视图列添加多个设置。我知道如何将一个特定设置应用于列。我浏览了他们的网站文档,但找不到这样的例子。我知道它可以做到,而且可能真的很容易,但在任何地方都找不到它的例子。
@{
var grid = Html.DevExpress().GridView(
settings =>
{
settings.Name = "gvMyGridView";
settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
//Allows sorting etc
settings.CallbackRouteValues = new { Controller = "Home", Action = "MyGridPartial" };
settings.ClientSideEvents.BeginCallback = "OnBeginCallback";
settings.Columns.Add("ColumnA").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
//settings.Columns.Add("ColumnA").Width = Unit.Pixel(75);
//As you can see above i want sort order set and the width set but am unable to do so
settings.Columns.Add("ColumnB").Width = Unit.Pixel(175);
settings.Columns.Add("ColumnC").Width = Unit.Pixel(175);
//Filter settings
settings.Settings.ShowFilterRow = true;
settings.Settings.ShowFilterRowMenu = true;
settings.CommandColumn.ClearFilterButton.Visible = true;
//Inline editing
settings.KeyFieldName = "Id";
});
if (ViewData["EditError"] != null){
grid.SetEditErrorText((string)ViewData["EditError"]);
}
}
@grid.Bind(Model).GetHtml()
我上面的例子很容易解释。也许我必须在它自己的添加属性上创建我的列,然后手动添加它。不确定,因为这是我第一次使用 MVC Devexpress Gridviews。任何意见是极大的赞赏。