gpt4 book ai didi

gridview - MVC Devexpress Gridview 列,如何向特定列添加多个设置?

转载 作者:行者123 更新时间:2023-12-02 19:39:52 25 4
gpt4 key购买 nike

我正在尝试向我的 mvc GridView 列添加多个设置。我知道如何将一个特定设置应用于列。我浏览了他们的网站文档,但找不到这方面的示例。我知道这是可以做到的,而且可能非常简单,但在任何地方都找不到它的示例。

@{
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。非常感谢任何建议。

最佳答案

settings.Columns.Add(column =>
{
column.FieldName = "Title";
column.Width = System.Web.UI.WebControls.Unit.Percentage(30);
column.SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
//other settings for column
});

关于gridview - MVC Devexpress Gridview 列,如何向特定列添加多个设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14218798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com