HI Team,
I would like to bind the columns for the Gridveiw according to the collection what i am passing from the controller.
Below is the code snippet shows like i have hardcoded the column name like
"settings.Columns.Add("Name").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
settings.Columns.Add("Amount");".
However how i need achieve the functionality without mentioning the column names in the partial view. My intension to do is i would like to create a partial view with complete dynamic GridView.
In Controller screen:
----------------------------
objCustomer = new Customer();
objCustomer.Code = 200;
objCustomer.Name = "Laptop";
objCustomer.Amount = 40000;
customers.Add(objCustomer);
return View("Index", customers);
In Partial View
-------------------
@Html.DevExpress().GridView(
settings =>
{
settings.Name = "myGridView";
settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPart" };
settings.Width = 450;
settings.Columns.Add("Name").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
settings.Columns.Add("Amount"** );
settings.SettingsPager.PageSize = 1;
settings.SettingsPager.FirstPageButton.Visible = true;
settings.SettingsPager.LastPageButton.Visible = true;
settings.CommandColumn.Visible = true;
var column = settings.Columns.Add("Code", MVCxGridViewColumnType.HyperLink);
DevExpress.Web.ASPxEditors.HyperLinkProperties properties = column.PropertiesEdit as DevExpress.Web.ASPxEditors.HyperLinkProperties;
String urlFormatString = Url.Action("EditingEdit", "Home", new RouteValueDictionary(new
{
Code = "{0}"
}));
properties.NavigateUrlFormatString = HttpUtility.UrlDecode(urlFormatString);
properties.TextField = "Code";
}).Bind(Model).GetHtml()