From 477a99976630a417316624903b0eedbd7197a4c4 Mon Sep 17 00:00:00 2001
From: Dimo Dimov <961014+dimodi@users.noreply.github.com>
Date: Tue, 12 Aug 2025 11:26:32 +0300
Subject: [PATCH 1/3] docs(ComboBox): Revamp Rebind example
---
components/combobox/refresh-data.md | 79 ++++++++++++++---------------
1 file changed, 37 insertions(+), 42 deletions(-)
diff --git a/components/combobox/refresh-data.md b/components/combobox/refresh-data.md
index d9e9473601..c7829ea6ee 100644
--- a/components/combobox/refresh-data.md
+++ b/components/combobox/refresh-data.md
@@ -24,67 +24,62 @@ In this article:
To refresh the ComboBox data when using [`OnRead`](slug:components/combobox/events#onread), call the `Rebind` method of the TelerikComboBox reference. This will fire the `OnRead` event and execute the business logic in the handler.
````RAZOR
-@* Clicking on the Rebind button will delete the first option from the dropdown and refresh the data *@
-
@using Telerik.DataSource.Extensions
-Rebind
+Remove First Data Item and Rebind
+
+ @bind-Value="@ComboBoxValue"
+ OnRead="@OnComboBoxRead"
+ TItem="ListItem"
+ TValue="int"
+ ValueField="@nameof(ListItem.Id)"
+ TextField="@nameof(ListItem.Text)"
+ Width="200px">
@code{
- public int SelectedValue { get; set; }
- List AllData { get; set; } = new List();
- public TelerikComboBox ComboBoxRef { get; set; }
-
- async Task ReadItems(ComboBoxReadEventArgs args)
- {
- await Task.Delay(1000);
- args.Data = AllData.ToDataSourceResult(args.Request).Data;
- }
+ public TelerikComboBox? ComboBoxRef { get; set; }
+ private List AllData { get; set; } = new();
+ private int ComboBoxValue { get; set; }
- protected override void OnInitialized()
+ private void RebindComboBox()
{
- List products = new List();
- for (int i = 0; i < 200; i++)
+ if (AllData.Count > 0)
{
- products.Add(new Product()
- {
- ProductId = i,
- ProductName = "Product" + i.ToString(),
- SupplierId = i,
- UnitPrice = (decimal)(i * 3.14),
- UnitsInStock = (short)(i * 1),
- });
+ AllData.RemoveAt(0);
}
- AllData = products;
+ ComboBoxValue = AllData.FirstOrDefault()?.Id ?? default;
+
+ ComboBoxRef?.Rebind();
}
- public class Product
+ private async Task OnComboBoxRead(ComboBoxReadEventArgs args)
{
- public int ProductId { get; set; }
- public string ProductName { get; set; }
- public int SupplierId { get; set; }
- public decimal UnitPrice { get; set; }
- public short UnitsInStock { get; set; }
+ var result = await AllData.ToDataSourceResultAsync(args.Request);
+ args.Data = result.Data;
+ args.Total = result.Total;
}
- private void RebindComboBox()
+ protected override void OnInitialized()
{
- if (AllData.Count > 0)
+ for (int i = 1; i < 5; i++)
{
- AllData.RemoveAt(0);
+ AllData.Add(new ListItem()
+ {
+ Id = i,
+ Text = $"ListItem {i}"
+ });
}
- ComboBoxRef.Rebind();
+ ComboBoxValue = AllData.First().Id;
+ }
+
+ public class ListItem
+ {
+ public int Id { get; set; }
+ public string Text { get; set; } = string.Empty;
}
}
````
@@ -232,4 +227,4 @@ To refresh the ComboBox data when using [`OnRead`](slug:components/combobox/even
* [ObservableCollection](slug:common-features-observable-data)
* [INotifyCollectionChanged Interface](https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.inotifycollectionchanged?view=netframework-4.8)
- * [Live Demos](https://demos.telerik.com/blazor-ui)
\ No newline at end of file
+ * [Live Demos](https://demos.telerik.com/blazor-ui)
From 1cf73bfc1967d3386ecbba040b368ad8762dd195 Mon Sep 17 00:00:00 2001
From: Dimo Dimov <961014+dimodi@users.noreply.github.com>
Date: Tue, 12 Aug 2025 11:48:59 +0300
Subject: [PATCH 2/3] Update components/combobox/refresh-data.md
---
components/combobox/refresh-data.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/combobox/refresh-data.md b/components/combobox/refresh-data.md
index c7829ea6ee..f1e070d43b 100644
--- a/components/combobox/refresh-data.md
+++ b/components/combobox/refresh-data.md
@@ -64,7 +64,7 @@ To refresh the ComboBox data when using [`OnRead`](slug:components/combobox/even
protected override void OnInitialized()
{
- for (int i = 1; i < 5; i++)
+ for (int i = 1; i <= 5; i++)
{
AllData.Add(new ListItem()
{
From 6a300875c51c3a249578aaa4352977fed25292d2 Mon Sep 17 00:00:00 2001
From: Dimo Dimov <961014+dimodi@users.noreply.github.com>
Date: Tue, 12 Aug 2025 11:49:26 +0300
Subject: [PATCH 3/3] Update components/combobox/refresh-data.md
---
components/combobox/refresh-data.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/combobox/refresh-data.md b/components/combobox/refresh-data.md
index f1e070d43b..530d13430d 100644
--- a/components/combobox/refresh-data.md
+++ b/components/combobox/refresh-data.md
@@ -45,7 +45,7 @@ To refresh the ComboBox data when using [`OnRead`](slug:components/combobox/even
private void RebindComboBox()
{
- if (AllData.Count > 0)
+ if (AllData.Count > 1)
{
AllData.RemoveAt(0);
}