search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Load resource data via ajax doesn't expand child nodes

Asked by Graham
5 years ago.

I have the javascript version of DayPilot for which I am loading the resources by an ajax call.

<script type="text/javascript">
$(function () {
var data = $.post('/Schedules/GetVenuesAndRooms', function (data) {
dp.resources = data;

var dp = new DayPilot.Scheduler("dp");
dp.treeEnabled = true;

dp.startDate = new Date().toJSON().slice(0, 10);

The output from the ajax call looks like:

[{"id":11,"name":"Dublin - EIRE","children":[]},{"id":24,"name":"My Venue","children":[]},{"id":25,"name":"Graham's House","children":[{"id":0,"name":"My Front Room"}]}]

The problem I have is that the main venues show but if there are any children then I want them to be expanded by default but they are collapsed. I thought that setting the treeEnabled property would expand them but perhaps it is due to the way I am loading the data?

Answer posted by Dan Letecky [DayPilot]
5 years ago.

You can expand the children by adding expanded: true property to the parent node:

[{"id":11,"name":"Dublin - EIRE","children":[]},{"id":24,"name":"My Venue","children":[]},{"id":25,"name":"Graham's House", "expanded":true, "children":[{"id":0,"name":"My Front Room"}]}]

See also:

Let me know if it didn't help.

This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.