Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Unable to bind chilld elements in igHierarchical grid
posted

Hi,

I am trying to bind json data to my Hieararchical grid.Following is the initialization:

$("#AllTasksGrid").igHierarchicalGrid({
initialDataBindDepth: 1, 
showHeader: true,
responseDataKey: 'rows',
dataSource: '@Url.Action("GetAllTasksAndActivities", "Home")',
primaryKey: "Id",
autoGenerateColumns: false,
columns: [
{ headerText: "Id", key: "id", dataType: "string", hidden: true },
{ headerText: "Code", key: "businessCode", dataType: "string"},
{ headerText: "Type", key: "taskType", dataType: "string"},
{ headerText: "Task/Activity Name", key: "taskName", dataType: "string"},
{ headerText: "Country", key: "countryList", dataType: "string" },
{ headerText: "Status", key: "Status", dataType: "string" },
{ headerText: "Start Date", key: "StartDate", dataType: "string" },
{ headerText: "Deadline", key: "Deadline", dataType: "string" }
],
autoGenerateLayouts: false,
defaultChildrenDataProperty: "Activities",
columnLayouts: [
{
key: "Activities",
responseDataKey: "Activities",
childrenDataProperty: "Activities",
autoGenerateColumns: false,
primaryKey: "ActivityId",
foreignKey: "Id",
columns: [
{ key: "ActivityId", headerText: "ID", dataType: "string" },
{ key: "Name", headerText: "Name", dataType: "string" },
{ key: "Status", headerText: "Status", dataType: "string" },
{ key: "StartDate", headerText: "Start Date", dataType: "string" },
{ key: "Deadline", headerText: "Deadline", dataType: "string" }
]
}
],

features: [
{
name: "Paging",
type: "remote",
pageSize: 10,
recordCountKey: 'records'
},
{
name: "Sorting",
type: "remote"
},
{
name: "Tooltips",
columnSettings: [
{ columnKey: "taskname", allowTooltips: true }
],
visibility: "overflow",
showDelay: 100,
hideDelay: 100
}

]
});

--------------------------------------------------------------------------------------------------------------------------------

Following is the json data i am receiving

{"page":0,

"records":896,

"rows":[{"id":359,"businessCode":"12121212","taskType":"Task","taskName":"Task","countryList":"AAA","Status":"P","StartDate":"2012-10-23","Deadline":"",
"Activities":
[{"ParentTaskId":0,
"ActivityId":480,
"Name":"Update Acitivy 2 new 1 2 3",
"IsNameEnabled":false,
"BusinessCode":null,
"AssignedTo":null,
"IsAssignedToEnabled":false,
"AssignedToName":null,

........

--------------------------------------------------------------------------------------------------------------------------------

However when the grid renders it only renders the parent rows but child values are empty. Is there something wrong with the initialization?

Parents
No Data
Reply
  • 4315
    Offline posted

    Hi, Sudipto Roy.

    Thank you for using our product. 

    You may try remove the responseDataKey of the child column layout. This is bacause in the data source you have "Activities": [{...}]. If you don't want to remove the responseDataKey and preserve the same configuration, then you need to modify the data source to so that the JSON for the child layout to be -  "Activities": {"Activities": [{...}]}.

    Best regards,

    Nikolay Alipeiv

Children