DataGrid - instantiating with Razor syntax not working in .Net Core

Based on the examples I've seen posted int he forum, it's possible to instantiate A DataGrid using Razor syntax. It doesn't seem to be working for me.
This displays a data grid and the data I want it to show:
When I replace the working code above with the Razor syntax below, I get a blank page:
@{
var DataGrid = new Syncfusion.EJ2.Grids.Grid()
{
DataSource = "ViewBag.dataSource",
AllowPaging = false,
AllowSorting = false,
AllowResizing = false,
AllowFiltering = false,
AllowGrouping = false,
Toolbar = new List() { "Add", "Edit", "Delete", "Update", "Delete", "Cancel", "Search" },
EditSettings = new Syncfusion.EJ2.Grids.GridEditSettings() { AllowAdding = true, AllowEditing = true, AllowDeleting = true, Mode = Syncfusion.EJ2.Grids.EditMode.Normal},
Columns = new List {
new Syncfusion.EJ2.Grids.GridColumn(){ Field="TrainingID", HeaderText="ID", IsPrimaryKey=true },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="Date", HeaderText="Date", EditType = "datepickeredit", Format="yDm"},
new Syncfusion.EJ2.Grids.GridColumn(){ Field="Type", HeaderText="Type" },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="Modality", HeaderText="Modality" },
new Syncfusion.EJ2.Grids.GridColumn(){ Field="Description", HeaderText="Description" },
}
};
}

1 Reply

TS Thiyagu Subramani Syncfusion Team July 31, 2020 09:04 AM UTC

Hi Scot, 

Thanks for contacting Syncfusion forum. 

We checked your reported problem but unfortunately were unable to reproduce it from our end.  So, Before proceed further, please share below details. 

  • Video/image representation of your issue.
  • Syncfusion package and NuGet package version
  • You facing issue like blank page means empty data bounded in grid or else?
  • Share complete startup.cs page
  •  Are you using grid as Hierarchy structure?
  • If possible, share issue reproducing sample.
  • Facing any script error.

Please get back to us, if you need any further assisatcance. 

Regards, 
Thiyagu S 


Loader.
Up arrow icon