コード例 #1
0
        private async Task UpdateNodesAsync()
        {
            var oldNodesVisible = CollectionsVisible;

            try
            {
                UI = await TreeService.GetNodesAsync(CollectionAlias, ParentPath, _pageNr, PageSize);

                if (UI == null)
                {
                    return;
                }

                CollectionsVisible = UI.Nodes.ToDictionary(x => x.Id, x => x.DefaultOpenCollections);

                // restore the view state with the new nodes
                if (oldNodesVisible != null)
                {
                    foreach (var node in oldNodesVisible.Where(x => x.Value))
                    {
                        if (CollectionsVisible.ContainsKey(node.Key))
                        {
                            CollectionsVisible[node.Key] = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Error = ex.Message;
            }

            StateHasChanged();
        }