Index.cshtml
<ejs-grid id="Grid" allowPaging="true" allowSorting="true" allowFiltering="true" toolbar="@(new List<string>() {"Search" })">
<e-data-manager url="@Url.Action("UrlDatasource", "Home1",new { Area = "" })" adaptor="UrlAdaptor"></e-data-manager>
------------
</ejs-grid> |
Areas/Products/Controllers/Home1
namespace WebApplication7.Controllers
{
[Area("Products")]
public class Home1Controller : Controller
{
------------
}
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
IEnumerable DataSource = OrdersDetails.GetAllRecords();
-----------
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);
}
} |
Startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env){
app.UseMvc(routes =>
{
routes.MapAreaRoute(
name: "MyAreaProducts",
areaName: "Products", // here you have to add your areaName where to fetch
template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
routes.MapAreaRoute(
name: "MyAreaServices",
areaName: "Services",
template: "Services/{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
} |
Index.cshtml
<ejs-grid id="Grid" allowPaging="true" allowSorting="true" allowFiltering="true" toolbar="@(new List<string>() {"Search" })">
<e-data-manager url="@Url.Action("UrlDatasource", "Home1",new { Area = "" })" adaptor="UrlAdaptor"></e-data-manager>
------------
</ejs-grid> |
Areas/Products/Controllers/Home1
namespace WebApplication7.Controllers
{
[Area("Products")]
public class Home1Controller : Controller
{
------------
}
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
IEnumerable DataSource = OrdersDetails.GetAllRecords();
-----------
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);
}
} |
Startup.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env){
--------
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapAreaControllerRoute(
"Products",
"Products", // here you have to set your area name
"{area:exists}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
"default", "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
} |