You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: common-features/observable-data.md
+21-1Lines changed: 21 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Databound components can benefit from live data - when the data source collectio
14
14
15
15
When the `Data` of the component is a collection that implements the `INotifyCollectionChanged` interface (such as `ObservableCollection`), the Telerik components subscribe to its `CollectionChanged` event to update. This means that adding items, removing items, or clearing the collection updates the components (its `.Add()`, `.Remove()` and `.Clear()` methods).
16
16
17
-
The following components support observable data:
17
+
The following components support observable data for their `Data` parameter:
18
18
19
19
* AutoComplete
20
20
@@ -34,6 +34,26 @@ The following components support observable data:
34
34
35
35
The Scheduler, Menu, Drawer, ContextMenu will receive this feature in a future release.
36
36
37
+
## Refresh Data
38
+
39
+
The most common reason you would use an ObservableCollection is to make a component (like a grid, treeview, treelist, dropdown) change or react when you change that collection.
40
+
41
+
When you want to refresh the component data source like that, there are two important framework behaviors you need to be aware of:
42
+
43
+
* Observable collections fire the `CollectionChanged` event (which the Telerik components subscribe to) only when their `Add`, `Remove` and `Clear` methods are called.
44
+
45
+
They do not fire it when you change the value of a field of one of their elements.
46
+
47
+
* In Blazor, the framework will fire the `OnParametersSet` event of a child component (which is how child components can react to outside changes) only when it can detect a change in the object it receives through the corresponding parameter (like `Data` for the data sources of Telerik components). This detection works as follows:
48
+
49
+
* For primitive types (such as numbers, strings), this happens when their value changes.
50
+
51
+
* For complex types (such as data collections like `List`, or any `IEnumerable`, and application-specific models/objects), this happens when the object reference changes.
52
+
53
+
Thus, you would usually need to create a `new` reference for the view-model field (such as `TreeViewData = new List<MyTreeViewItem>(theUpdatedDataCollection);`) when you want the component to update.
54
+
55
+
You can find some more explanations and examples for the Grid component in the [Force a Grid to Refresh]({%slug grid-force-refresh%}) Knowledge Base article.
0 commit comments