Hi Bassem,
Thanks for your interest in Syncfusion products.
We have validated your query and the grid data will be render based on the “Field” property of the column. The HeaderText in column used for showing column’s header. We suspect you are not defined correct “Field” value for column and please refer the below code examples.
|
Razor Code:
@Html.EJS().Grid("Grid").DataSource((IEnumerable<Object>)ViewBag.DataSource).Columns((Syncfusion.EJ2.Grids.GridColumn[])ViewBag.Column).AllowPaging().AllowSorting().PageSettings(p=>p.PageSize(5)).Render()
|
|
Controller Code:
var columns = new Syncfusion.EJ2.Grids.GridColumn[3];
columns[0] = new Syncfusion.EJ2.Grids.GridColumn { Field = "OrderID", HeaderText = "Order ID", Width = "100" };
columns[1] = new Syncfusion.EJ2.Grids.GridColumn { Field = "CustomerID", HeaderText = "Customer ID", Width = "100" };
columns[2] = new Syncfusion.EJ2.Grids.GridColumn { Field = "Freight", HeaderText = "Freight", Width = "100", Format="C2" };
ViewBag.Column = columns;
ViewBag.DataSource = OrdersDetails.GetAllRecords(); |
For your reference, we have created a simple sample based on your requirement that can be downloaded from the below location
Please let us know, if you need any further assist on this.
Regards,
Ramdhas Ueikattan