Dhtmlxgantt readonly

hello,can you give me a dhtmlxgantt readonly example?
because when i set ‘gantt.getTask(1).editable = true’ will prompt ‘Task not found id=1’

Hi @isWFF,
I can’t say for sure without an example of your code, but your problem could have occurred if you tried to make one task editable before loading the data.
In the following snippet, you can see a workable example of how you can make a single task editable:
http://snippet.dhtmlx.com/8a5238139
If this answer didn’t help you, and you still have an issue, could you reproduce it in the above fragment, click the share button and send me the link?

Reference to your sample code, still prompt“Task not found id=1”,My data is from the database. The given ID must exist,Loading data uses load, not parse.
as follows:
http://snippet.dhtmlx.com/a9054abdb

Hi @isWFF,
Thank you for the clarification. I reproduced the issue locally, and it occurred, because you are trying to get a task, which is not loaded yet. At first, you should check if your data is loaded. In order to do this, you can open your page with gantt => wait for the page is fully loaded => open console(in developer tools) and call gantt.getTask(2) . If console will return a response like this :
{id: 2, text: "Task #1", start_date: Tue Apr 02 2013...} , all is ok and your tasks loaded from the server correctly.

To wait full data load and work with tasks only after that, you should use some promise/callback function, here is an example of workable code( tasks.json file is located in the same folder as index file):

gantt.load("tasks.json").then(function() { var task = gantt.getTask(2); task.editable = true; })

Also, if you want to avoid using timeouts/callbacks you can use the onLoadEnd event, which fires only when the data from the data source is fully loaded:
gantt.attachEvent("onLoadEnd", function(){ gantt.getTask(2).editable = true; });
API for the:
gantt.load:
https://docs.dhtmlx.com/gantt/api__gantt_load.html
onLoadEnd:
https://docs.dhtmlx.com/gantt/api__gantt_onloadend_event.html

The function has been realized. Thank you.