I'm using DynamicData from ReactiveUI and transformed a list into a tree and output a `ReadOnlyObservableCollection` which is used as `DataSource`. The `EjsTreeView` mapping is applied but doesn't show the text nor the arrows but renders the first root children (totally empty but `<li>`'s are visible). When I try to use `NodeTemplate` I get nulls on `@context`.
How complex can a type be in the `DataSource`?
FileTree.razor
```
<EjsTreeView TValue="FileInfoViewModel">
<TreeViewFieldsSettings TValue="FileInfoViewModel"
DataSource="@FileInfoViewModels"
Id="Key"
Text="Name"
Child="@("Children")"
Selected="Selected"
Expanded="Expanded">
</TreeViewFieldsSettings>
</EjsTreeView>
@code
{
public ReadOnlyObservableCollection<FileInfoViewModel> FileInfoViewModels;
private readonly CompositeDisposable cleanup = new CompositeDisposable();
protected override void OnInitialized()
{
base.OnInitialized();
var tree = FileSystemService.FileInfoTree;
tree.Bind(out FileInfoViewModels)
.DisposeMany()
.Subscribe()
.DisposeWith(cleanup);
}
public void Dispose()
{
cleanup.Dispose();
}
}
```
FileInfoViewModel.cs
```
public class FileInfoViewModel : ReactiveObject, IDisposable
{
private readonly CompositeDisposable cleanup = new CompositeDisposable();
public string Key { get; }
public string Name => FileInfo.Name;
public Optional<FileInfoViewModel> Parent { get; }
public VirtualFileInfo FileInfo { get; }
[Reactive]
public bool Expanded { get; set; }
[Reactive]
public bool Selected { get; set; }
private ReadOnlyObservableCollection<FileInfoViewModel> children;
public ReadOnlyObservableCollection<FileInfoViewModel> Children => children;
internal FileInfoViewModel(Node<VirtualFileInfo, string> node, FileInfoViewModel parent = null)
{
Key = node.Key;
Parent = parent;
FileInfo = node.Item;
var childrenLoader = new Lazy<IDisposable>(() =>
node.Children
.Connect()
.Transform(e => new FileInfoViewModel(e, this))
.Bind(out children)
.DisposeMany()
.Subscribe());
var shouldExpand = node.IsRoot
? Observable.Return(true)
: Parent.Value.WhenAnyValue(x => x.Expanded);
shouldExpand
.Where(isExpanded => isExpanded)
.Take(1)
.Subscribe(_ => childrenLoader.Value.DisposeWith(cleanup))
.DisposeWith(cleanup);
}
public void Dispose()
{
cleanup.Dispose();
}
}
```
FileSystemService (partial)
```
public IObservableCache<VirtualFileInfo, string> FileInfos => fileInfoSourceCache.AsObservableCache();
public IObservable<IChangeSet<FileInfoViewModel, string>> FileInfoTree =>
FileInfos
.Connect()
.TransformToTree(fileInfo => Path.GetDirectoryName(fileInfo.VirtualPath),
Observable.Return<Func<Node<VirtualFileInfo, string>, bool>>(node => node.IsRoot))
.Transform(node => new FileInfoViewModel(node));
```
If you are asking why I don't use the `FileManager` because I don't want the `FileManager` communicate with Ajax and it cannot accept local datas.