jeffkr
December 13, 2019, 4:28pm
#1
Can we group by a nested property?
For example the “relation_property” is nested deeply within the data array. I’d like to be able to do:
relation_property: 'nested.property.groupByMe'
[
{
id: 1,
nested: {
property: {
groupByMe: 'Group Me'
}
}
}
]
Is it possible?
ramil
December 16, 2019, 10:16am
#2
Hello Jeffkr,
It will not work that way as the relation_property
is a string parameter:
https://docs.dhtmlx.com/gantt/desktop__grouping.html#groupingtasks
But you can work around it by saving a nested property in a temporary variable and group by that variable. Here is an example of how might be implemented:
http://snippet.dhtmlx.com/c9073884b
However, you will need to use other workarounds as you cannot update the nested property by specifying it in the map
variable in the lightbox configuration. You need to use the onLightboxSave
event handler to update that property:
https://docs.dhtmlx.com/gantt/api__gantt_onlightboxsave_event.html
jeffkr
December 16, 2019, 7:51pm
#3
Thanks, that’s the work around I already had.
If you pass in a string that contain “.”, use that as a delimiter and split your way down to the nested property. That’s the idea I had to keep the API cleaner instead of manually remapping my data.
ramil
December 17, 2019, 7:17am
#4
Hello Jeffkr,
Thank you for the suggestion. I will forward it to the dev team.