From 78567f3940694d1fc478fd17ef063ec8f6488372 Mon Sep 17 00:00:00 2001
From: Tsvetomir Hristov <106250052+Tsvetomir-Hr@users.noreply.github.com>
Date: Thu, 6 Jun 2024 15:36:53 +0300
Subject: [PATCH] docs(Grid): example code polish (#2145)
* docs(Grid): example code polish
* docs(Grid): apply suggestions
* docs(Grid): caption change
---
knowledge-base/grid-add-column-from-code.md | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/knowledge-base/grid-add-column-from-code.md b/knowledge-base/grid-add-column-from-code.md
index 8a26f845f..052f6bc2b 100644
--- a/knowledge-base/grid-add-column-from-code.md
+++ b/knowledge-base/grid-add-column-from-code.md
@@ -27,13 +27,13 @@ I want to add a custom Grid column programmatically. I would also like to define
## Solution
-You can use the [`RenderTreeBuilder`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.rendering.rendertreebuilder?view=aspnetcore-6.0) class to create a GridColumn from the C# portion of the application.
+You can use the [`RenderFragment Delegate`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.renderfragment?view=aspnetcore-8.0) to create a `GridColumn` from the C# portion of the application.
->caption Add a GridColumn from code
+>caption Add a Grid column from code
````CSHTML
-@* Use the Render Tree Builder to add a grid column. Click on the Add a column button to see the result *@
+@* Use the RenderFragment to add a grid column. Click on the Add a column button to see the result *@
Add a column
@@ -58,15 +58,9 @@ You can use the [`RenderTreeBuilder`](https://docs.microsoft.com/en-us/dotnet/ap
private RenderFragment CustomGridColumnFromCode { get; set; }
- private RenderFragment AddAGridColumn() => builder =>
+ private RenderFragment AddAGridColumn() => __builder =>
{
- builder.OpenComponent(0, typeof(GridColumn));
-
- builder.AddAttribute(0, "Field", "CustomDateField"); //The Field for the Column
- builder.AddAttribute(1, "Title", "From code behind"); //The Title for the Column
- builder.AddAttribute(2, "DisplayFormat", "{0:dd MMM yy}"); //The DisplayFormat for the Column
-
- builder.CloseComponent();
+
};
public IEnumerable MyData = Enumerable.Range(1, 30).Select(x => new SampleData