I have 3 classes being them Contact, Sector, Unit so I have Contact with one-to-many relationship with Sector and Unit generating Json with many layers, making it impossible for JQuery Bootgrid to access these fields.
Checking JQuery Bootgrid documentation I noticed that it does not support the data-column-id="Drive.Name"
Contact Class
public class Contato
{
[Key]
public int ContatoID { get; set; }
public string Nome { get; set; }
public int UnidadeID { get; set; }
public Unidade Unidade { get; set; }
public int SetorID { get; set; }
public Setor Setor { get; set; }
}
Drive Class
public class Unidade
{
[Key]
public int UnidadeID { get; set; }
public string Nome { get; set; }
}
Industry Class
public class Setor
{
[Key]
public int SetorID { get; set; }
public string Nome { get; set; }
}
These classes are generating the following JSON
rows: [
{
ContatoID: 4,
Nome: "Luiz",
UnidadeID: 1,
Unidade: {
UnidadeID: 1,
Nome: "Oeste Paulista Setor 1"
},
}
The return of the Controller responsible for returning Json is this
return Json(new {
rows = contatosPaginados.ToList(),
current = current,
rowCount = rowCount,
total = total
}, JsonRequestBehavior.AllowGet);
The question is how do I make Json come all on the same level?
[{
ContatoID: 4,
Nome: "Luiz",
Ramal: "9500",
UnidadeID: 1,
NomeUnidade: "Oeste Paulista Setor 1"
}]