I am attempting to add more than one setting to my mvc grid view columns. I know how to apply one specific setting to a column. I went through their website documentation and was unable to find an example of this. I know it can be done and is probably really easy but can't find an example of it anywhere.
@{
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()
My example above is pretty self explanatory. Maybe I have to create my column on its own add properties to it then add it in manually. Unsure as this is my first run with MVC Devexpress Gridviews. Any advice is greatly appreciated.