Posted 8 September 2017, 11:19 pm EST
Hi,
When I add an area to my asp.net core MVC application, Flexgrid does not render.
Steps to reproduce:
-
Create a new C1 Asp.Net Core MVC Application (.NET Core) project using default template settings
-
Add a new folder called Areas to the project
-
Create a sub-folder called TestArea and sub folders for Controllers, Models and Views
-
Under the created Views folder, copy and paste _ViewImports.cshtml and _ViewStart.cshtml from the root Views folder of the project
-
Add a simple model class:
[csharp]
public class TestModel
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
}
[/csharp]
- Add a new controller called TestController to the Areas\TestArea\Controllers folder
- Add the attribute [Area(“TestArea”)] to the TestController class definition
- Modify Startup.cs and include the following route convention:
[csharp]
routes.MapRoute(name: “areaRoute”,
template: “{area:exists}/{controller=Home}/{action=Index}”);
[/csharp]
- In the Index action of the TestController class, instantiate a List to pass to the view:
[csharp]
List model = new List
{
new TestModel() { Prop1 = ‘Test Value’, Prop2 = ‘Test Value 2’ }
};
return View(model);
[/csharp]
- Create a folder under Areas\TestArea\Views called Test and add an Index.cshtml file with the following code:
@model IEnumerable<C1MvcApplication.Areas.TestArea.Models.TestModel>
<c1-flex-grid id="flexgrid" is-read-only="true" height="800px">
<c1-items-source source-collection="Model"></c1-items-source>
</c1-flex-grid>
- Run the application and navigate to /TestArea/Test and note that ASP.NET routes correctly to the area/controller/action/ and renders the corresponding view but does not render the flexgrid. Inspecting the DOM shows that the markup for the flexgrid is present, however it does not display.
Modifying the above steps to move the Controller, Model, and Views outside of the area and placing them in the corresponding folders in the root of the project, the flexgrid renders with the sample data populated.
Could someone please explain why this is the case and if there is a workaround for the above to get the FlexGrid to correctly render in MVC Areas?
Thanks