To expand/collapse all items programmatically, for example via custom button clicks, use the first approach (expandedKeys) and set the collection to an empty array to collapse all items, and to an array, containing all items IDs (or other custom identifier property).
Here is an example, demonstrating the described approach:
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.