- Home
- Forum
- ASP.NET MVC (Classic)
- Grid Hierarchy - Child table dosen't show
Grid Hierarchy - Child table dosen't show
Ive created at Hierarchy grid and the grid shows just fine in my .aspx page
But when i press the row to se the child table i get this:
When i debug my code i can see that the ActionResult ChildGrid does return a result
I've hidden the row where the id is for joining but it is passed to the code behind
My aspx:
@{ Html.Syncfusion().Grid<DataRow>("GridSrc").Datasource(Model)
.Caption("Hændelser")
.AutoFormat(Skins.Metro)
.AllowResizing(true)
.AllowAutoWrap(true)
.ChildGrid(child => child.ChildGridTemplate(Html.Syncfusion().Grid<DataRow>("ChildGrid_${JoinId}").Caption("Overblik over hændelser").Mappers(map => map.Action("ChildGrid", new { joinid = "${JoinId}" })).ToChildGridTemplate())).ClientSideEvents(events => { events.OnLoad("hideGridColumn"); }).Render();
}
My codebehind:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ChildGrid(PagingParams args, string joinid)
{
DataTable table = new DataTable("Hændelser");
using (SqlConnection sqlCon = new SqlConnection(_sqlConString))
{
try
{
string sqlCmdQuery = @"SELECT
Navn
Maaned ,
Aar ,
Start_Dato ,
Slut_Dato ,
Type ,
Varighed ,
[Aktiv?]
FROM Statistik.VW_OverblikAlleHaendelser AS VOAH
WHERE VOAH.JoinId = '" + joinid +
"' ORDER BY Start_Dato";
SqlCommand sqlCmd;
sqlCmd = new SqlCommand(sqlCmdQuery);
sqlCmd.Connection = sqlCon;
sqlCon.Open();
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCmd);
sqlDataAdapter.Fill(table);
}
catch (Exception exception)
{
}
finally
{
if (sqlCon.State == ConnectionState.Open)
sqlCon.Close();
sqlCon.Dispose();
}
}
IEnumerable data = table.AsEnumerable().ToList();
return data.GridActions<DataRow>();
}
Regards
-Jacob
Thanks for using Syncfusion products.
Please let us know if you need any further assistance.
Regards,
Hariharan J.V.
Hi Jacob,
Thanks for your patience.
We suggest you to set datasource for child grid initially to avoid your issue. Please refer the below code snippets.
[Index.cshtml]
.ChildGrid(child =>
{
child.ChildGridTemplate(Html.Syncfusion().Grid<System.Data.DataRow>("ChildGrid_${OrderID}")
.Datasource((IEnumerable<System.Data.DataRow>)ViewData["data"])
.Caption("OrderDetails Grid")
.AutoFormat(Skins.Marble)
.EnablePaging()
.Mappers(map =>
{
map.Action("ChildGrid", new { OrderID = "${OrderID}" });
})
.ToChildGridTemplate());
})
[HomeController.cs]
public ActionResult Index()
{
ViewData["data"] = GetTable1(GetTable().Rows[0]["OrderID"].ToString()).AsEnumerable();
return View(GetTable());
}
For your convenience, we have prepared a simple sample to demonstrate this and the same can be downloaded from the below link.
Sample: DataTable_Hierarchygrid.zip
Could you please check the above sample and let us know if this is helpful.
Please let us know if you need further assistance.
Regards,
Balamurugan A.S
It worked :-)
Thanks you for your help :-)
-Jacob
Thanks for your update.
We are glad to know that your issue has been resolved. Please let us know if you have any other concerns so that we will be happy to help you out.
Regards,
Hariharan J.V.
- 4 Replies
- 3 Participants
-
JS Jacob Saugmann
- Sep 25, 2013 06:14 AM UTC
- Oct 7, 2013 04:41 AM UTC