mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-02-04 05:35:44 +00:00
DataGrid INotifyCollectionChanged support added
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Threading.Tasks;
|
||||
@@ -117,12 +118,37 @@ namespace Radzen
|
||||
if (_data != value)
|
||||
{
|
||||
_data = value;
|
||||
|
||||
if (_data != null && _data is INotifyCollectionChanged)
|
||||
{
|
||||
((INotifyCollectionChanged)_data).CollectionChanged += OnCollectionChanged;
|
||||
}
|
||||
|
||||
OnDataChanged();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when INotifyCollectionChanged CollectionChanged is raised.
|
||||
/// </summary>
|
||||
protected virtual void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
if (_data != null && _data is INotifyCollectionChanged)
|
||||
{
|
||||
((INotifyCollectionChanged)_data).CollectionChanged -= OnCollectionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the page size options.
|
||||
/// </summary>
|
||||
|
||||
@@ -1597,6 +1597,12 @@ namespace Radzen.Blazor
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
InvokeAsync(Reload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the DataGrid instance to initial state with no sorting, grouping and/or filtering.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user