I want to close the branch in the resource view,How can I do this?
Hi @isWFF,
If I understand you correctly, you want to make branches in the resources panel
closed by default, am I right?
In order to do this, you should change initItem
method of the resourcesStore
and set
item.open = false
instead of true
, like in this code fragment:
gantt.$resourcesStore = gantt.createDatastore({ name: gantt.config.resource_store, type: "treeDatastore", initItem: function(item) { item.parent = item.parent || gantt.config.root_id; item[gantt.config.resource_property] = item.parent; item.open = false; // this line will close branches return item; } });
So branches will be loaded in the closed state, like in the snippet below.
Also, if you want to close some resources branches directly from code, you can implement custom close/open
methods in the resourcesStore
, here is the snippet:
http://snippet.dhtmlx.com/470c951d2
Click the open/close QA
buttons to check how does it work.
API:
https://docs.dhtmlx.com/gantt/desktop__resource_management.html#resourceviewpanel
The task panel I want to close is not the resource panel. When I load the task panel, I use task. $open = false to close the task panel branch. But when I use the display resource view, the task branch is open. The function I want to achieve is that the task branch is still closed when I display the resource view
Hi @isWFF,
If you meant creating the resource view by grouping tasks based on some resource field, you can close these resources branches by closing each virtual
task, like in this code fragment:
gantt.eachTask(function (task){
if (task.$virtual) {
gantt.close(task.id)
console.log("Id Of the closed branch: ",task.id)
}
})
Here is the snippet of how it could be implemented:
http://snippet.dhtmlx.com/238a79757
If it is not the thing you need, could you please clarify the question with some screenshot or you can reproduce your scenario in the snippet below, click the share button and send me the link?
That’s what I want. Thank you