WPF and Xamarin supports data binding to INotifyCollectionChanged (ObservableCollection) and INotifyPropertyChanged.
This binding scenario is widely used.
So implementation of this feature allows WPF and Xamarin developers use their experience and code base in Blazor.
Hi Mark,
Currently, this item is not in development, so I updated the incorrect status.
At this stage, the components that support binding to an ObservableCollection are:
Here you can find a list of components that will support binding to observable data in a future release: https://docs.telerik.com/blazor-ui/common-features/data-binding/observable-data#telerik-components-that-will-support-observable-data-in-a-future-release.
Please let us know if you do not see the component that you want to use in any of those lists.
Regards,
Nadezhda Tacheva
Progress Telerik
Hi. Is this the right status?
The upcoming 2.7.0 release will implement this for the AutoComplete, ComboBox, DropDownList, MultiSelect and TreeView, in addition to the Grid that already has this feature. In future releases other components will receive this too (at the time of writing, the Menu and the Scheduler remain).
--Marin
Hi Igor,
This re-rendering happens without us doing it explicitly. Thus, adding another handler to PropertyChanged just adds more code to be executed, and we will also have to add if-checks everywhere it might be used to check if an event handler needs to be called to re-read the data. I think that this is actually more likely to cause performance issues than the standard blazor re-rendering. Nevertheless, this is something the dev team will review when we get to working on this task.
Regards,
Marin Bratanov
Progress Telerik
Hello, Martin
I checked your example and saw that both the TelerikGrid and the html table are updated when the value of Name property changes. This is due to the fact that all bound (displayed) properties of all elements of the source collection are reread (perhaps fully rerendered). It is possible in the case of long-term calculated properties or a large number of source collection elements or frequent changes, this will negatively affect performance. If the telerik grid subscribes to the PropertyChanged event, it will be able to read and rerender the value of only one property of only one element of the source collection.
Hello Igor,
Changing values should update the UI because Blazor should be monitoring this already. I am not sure this is something that must be logged. Give it a try on a simple page like this:
<TelerikButton OnClick="@UpdateRow2">Change row 2</TelerikButton>
<TelerikGrid Data="@MyData">
<GridColumns>
<GridColumn Field="@(nameof(SampleData.Id))" Width="120px" />
<GridColumn Field="@(nameof(SampleData.Name))" Title="Employee Name" Groupable="false" />
<GridColumn Field="@(nameof(SampleData.Team))" Title="Team" />
<GridColumn Field="@(nameof(SampleData.HireDate))" Title="Hire Date" />
</GridColumns>
</TelerikGrid>
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Team</th>
<th>Hire Date</th>
</tr>
</thead>
<tbody>
@foreach (var row in MyData)
{
<tr>
<td>@row.Id</td>
<td>@row.Name</td>
<td>@row.Team</td>
<td>@row.HireDate</td>
</tr>
}
</tbody>
</table>
@code {
void UpdateRow2()
{
MyData[1].Name = DateTime.Now.ToString();
}
public List<SampleData> MyData = Enumerable.Range(1, 5).Select(x => new SampleData
{
Id = x,
Name = "name " + x,
Team = "team " + x % 5,
HireDate = DateTime.Now.AddDays(-x).Date
}).ToList();
public class SampleData
{
public int Id { get; set; }
public string Name { get; set; }
public string Team { get; set; }
public DateTime HireDate { get; set; }
}
}
Regards,
Marin Bratanov
Progress Telerik
Hello Igor,
I updated the title to better explain what could be done (especially for people who are not familiar with WPF/Xamarin), and I also removed the leftover bits from the translator for clarity. I must also say that it is not very likely that we will subscribe to the PropertyChanged event, this is something the framework should do, we will probably only use the CollectionChanged event, like in the grid.
Regards,
Marin Bratanov
Progress Telerik