I am having a weird issue with the tree grid and a remote datasource. It has taken forever to get the grid to display correctly just because how the data is, but none the less, its finally working except for some reason it is duplicating the rows when rendered. The data looks like when you expand the company which has id of 0:
{
"result": [
{
"id": 1138,
"lor_order": 0,
"display_name": "Craig",
"reports_to": 0,
"has_children": 1,
"team_name": "Networking Team",
"report_order": 1,
"roles": "team_lead"
},
{
"id": 1141,
"lor_order": 0,
"display_name": "Paul",
"reports_to": 0,
"has_children": 1,
"team_name": "Software Team",
"report_order": 1,
"roles": "office_lead,team_lead"
},
{
"id": 1160,
"lor_order": 7,
"display_name": "Joel",
"reports_to": 0,
"has_children": 0,
"team_name": "",
"report_order": 1,
"roles": null
}
]
}
The grid code is:
This is what is rendered:
As you can see, the teams get duplicated with the one individual. They all are indented correctly the first time, but the second set is not indented. Any thoughts as to what is wrong?
Ok, I figured out what is happening. When it loads, it is loading all 4 but only displaying the company. Then when you expand it, it adds the 3 more inset to the company which is right.
Edit: So if I return just the company on initial load, nothing displays, so I can't even get it to where they need to expand it to make the query. Help please, lol!
Edit2: What is super interesting is dumping beforeRowDatabound clearly shows the data but rowDatabound never fires.
{
"query": {
"subQuery": null,
"isChild": false,
"distincts": [],
"queries": [
{
"fn": "onWhere",
"e": {
"isComplex": false,
"field": "reports_to",
"operator": "equal",
"value": null,
"ignoreCase": false
}
}
],
"key": "",
"fKey": "",
"expands": [],
"sortedColumns": [],
"groupedColumns": [],
"params": [
{
"key": "IdMapping",
"value": "id"
}
],
"lazyLoad": [],
"isCountRequired": true
},
"xhr": {},
"count": 1,
"result": [
{
"id": 0,
"lor_order": 0,
"display_name": "",
"team_name": "The Group",
"roles": null,
"report_order": true,
"has_children": true
}
],
"request": "POST",
"actual": {
"count": 1,
"result": [
{
"id": 0,
"lor_order": 0,
"display_name": "",
"team_name": "The Group",
"roles": null,
"report_order": true,
"has_children": true
}
],
"query": "SELECT option_value FROM wp_options WHERE option_name = '_transient_mepr_migrating' LIMIT 1"
},
"actionArgs": {},
"name": "beforeDataBound",
"cancel": true
}
Ok, I got this working, BUT there is NO WAY this is right. By adding the below, it causes the row to show and then I just had to set hasChildMapping and then the expandy icon shows up:
Edit: Not working again and I have no clue why. What I do know, is the double issue is the same in that when it loads the child, it also is loads their children as well in a separate call but is hiding them, so when you expand, it shows what already exists and then makes another data call and appends duplicate data in the wrong spot.
Well, I finally got it all working and I can say it had nothing to do with the foreign keys, because those actually work 100% with TreeGrid, so call it a feature not a bug I guess, lol. For whatever reason, regardless of the datasource, I had to have args.cancel in beforeDataBound. Then I had to make certain the data returned is only for the query being passed as the caching you spoke of really didn't matter because if I return all rows or not on initial load, every time you expand a row, it makes another call to the DB and thats where the duplicates come in. Noe