Resource collapsed property is not working

Hi everybody!

I have a resource list and button. I want the collapsed property of each item to be toggle when I press the button. like this;

const calendarSetCollapsed = (data, type) => {
  data.forEach((item) => {
    item.collapsed = type;
    if (item.children && item.children.length > 0) {
      calendarSetCollapsed(item.children, type);
    }
  });
  return data;
};

when i press the button collapsed properties are changed but not changed in the calendar.

thanks for answer!

1 Like

Iā€™m having the same problem.

Hi @Sefa_Ozturkmen and @Anil_Turan :wave:

Note that updating the array itself may not have any effect on the calendar, because the reference is not changed, it is still pointing to the same array. I suggest you to change the return statement of the function:

const calendarSetCollapsed = (data, type) => {
  data.forEach((item) => {
    item.collapsed = type;
    if (item.children && item.children.length > 0) {
      calendarSetCollapsed(item.children, type);
    }
  });
  return [...data];
};