MultiTable MultiRow (childrows) in MVC
MultiTable MultiRow (childrows) in MVC
Hello everybody
I've followed this example: https://datatables.net/examples/api/row_details.html.
I've used it in my MVC5 ASP .NET app and it worked fine
I'm using a controller and EF as model to get the data in two tables as such:
public ActionResult GetService()
{
using (MyDatabaseEntities dc = new MyDatabaseEntities())
{
dc.Configuration.LazyLoadingEnabled = false;
dc.Configuration.AutoDetectChangesEnabled = true;
var servicelist = dc.ServiceInfoes.OrderBy(a => a.ServiceID).ToList();
return Json(new { data = servicelist }, JsonRequestBehavior.AllowGet);
}
}~~~~
How do i get the data from my secound table into the child rows?
I can get data form my "table 1" into the child rows, but not the data from "table 2".
Does this have anything to do with the function (d) in the example?
Or do I need to modify my GetService Method to .include "table 2"? ~~~~
Thank you very much for your time all
Answers
I'm not familiar with MVC but maybe we can start with some basic questions:
One option is to include the table 2 data with the table 1 data and the format function can just access the table 2 data elements. This would require the server side script to be changed.
Another option that I would consider is to use
filter()
to get the data from table 2 based on the criteria from table 1.Kevin
Do you know of any problems when using EF's .Include with Json and DataTable?
Filter you say, will look into it.
Thank you