-
Notifications
You must be signed in to change notification settings - Fork 63
Documentation(954494) - Revamp How to topic in blazor platform #5883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Gayathri4135
wants to merge
16
commits into
hotfix/hotfix-v29.1.33
Choose a base branch
from
954494-how-to
base: hotfix/hotfix-v29.1.33
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0bfec2a
Documentation(954494) - Revamp How to topic in blazor platform
Gayathri4135 a603a4b
Updated the md file
Gayathri4135 b62f4d7
Update the md file
Gayathri4135 411c427
updated the md file
Gayathri4135 1237244
updated the md file
Gayathri4135 945b8bb
updated the md file
Gayathri4135 85793c6
Updated the md file
Gayathri4135 c187b57
Updated the md file
Gayathri4135 f162097
Updated the sample
Gayathri4135 4c11673
updated the md file
Gayathri4135 d94b75e
Updated the md file
Gayathri4135 d0e71c3
Updated the md file
Gayathri4135 bd377eb
Updated the md file
Gayathri4135 d843200
Updated the md file
Gayathri4135 164828e
updated the md file
Gayathri4135 d373c23
update the md file
Gayathri4135 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
526 changes: 438 additions & 88 deletions
526
blazor/datagrid/how-to/blazor-webassembly-data-grid-using-cli.md
Large diffs are not rendered by default.
Oops, something went wrong.
529 changes: 438 additions & 91 deletions
529
blazor/datagrid/how-to/blazor-webassembly-datagrid-using-visual-studio.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
blazor/datagrid/how-to/custom-helper-function-inside-loop-with-template.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
--- | ||
layout: post | ||
title: Use custom helper inside the loop with templates in Blazor DataGrid | Syncfusion | ||
description: Learn here all about Place cancel icon in search bar in Syncfusion Blazor DataGrid. | ||
Gayathri4135 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
platform: Blazor | ||
control: DataGrid | ||
documentation: ug | ||
--- | ||
|
||
# Use custom helper inside the loop with templates in Blazor DataGrid | ||
|
||
The Syncfusion Blazor DataGrid allows you to use custom helpers inside the loop with [Template](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.GridColumn.html?#Syncfusion_Blazor_Grids_GridColumn_Template) property of a column. This feature enables you to create complex templates that can incorporate additional helper functions. | ||
|
||
The customer rating column includes a custom template defined using `Template`. Inside this template, iterates through the item array and generates `<span>` tag, displayed as stars using the CSS below: | ||
Gayathri4135 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```css | ||
.e-grid .rating .star:before { | ||
content: '★'; | ||
} | ||
|
||
.e-grid .rating .star { | ||
font-size: 132%; | ||
color: lightgrey; | ||
} | ||
``` | ||
|
||
The class is dynamically assigned based on the result of the `isRatingGreater` method, highlighting the star using the CSS below: | ||
|
||
```css | ||
.e-grid .rating .star.checked { | ||
color: #ffa600; | ||
} | ||
``` | ||
|
||
This is demonstrated in the following example. | ||
|
||
{% tabs %} | ||
{% highlight razor tabtitle="Index.razor" %} | ||
|
||
@using Syncfusion.Blazor.Grids | ||
|
||
<SfGrid DataSource="@Orders" Height="300px"> | ||
<GridColumns> | ||
<GridColumn Field="OrderID" HeaderText="Order ID" TextAlign="TextAlign.Right" Width="90"></GridColumn> | ||
<GridColumn Field="CustomerID" HeaderText="Customer ID" Width="100"></GridColumn> | ||
<GridColumn HeaderText="Customer Rating" Width="120"> | ||
<Template> | ||
@{ | ||
var rating = (context as Order)?.Rating ?? 0; | ||
} | ||
<div class="rate"> | ||
<div class="rating"> | ||
@foreach (var i in Enumerable.Range(1, 5)) | ||
{ | ||
<span class="star @(IsRatingGreater(rating, i) ? "checked" : "")"></span> | ||
} | ||
</div> | ||
</div> | ||
</Template> | ||
</GridColumn> | ||
</GridColumns> | ||
</SfGrid> | ||
|
||
<style> | ||
.e-grid .rating .star:before { | ||
content: '★'; | ||
} | ||
|
||
.e-grid .rating .star { | ||
font-size: 132%; | ||
color: lightgrey; | ||
} | ||
|
||
.e-grid .rating .star.checked { | ||
color: #ffa600; | ||
} | ||
</style> | ||
|
||
@code { | ||
public List<Order> Orders { get; set; } | ||
|
||
protected override void OnInitialized() | ||
{ | ||
Orders = Order.GetAllRecords(); | ||
} | ||
|
||
private bool IsRatingGreater(int dataRating, int comparisonValue) | ||
{ | ||
return dataRating >= comparisonValue; | ||
} | ||
} | ||
|
||
{% endhighlight %} | ||
{% highlight c# tabtitle="Order.cs" %} | ||
|
||
public class Order | ||
{ | ||
public int OrderID { get; set; } | ||
public string CustomerID { get; set; } | ||
public int Rating { get; set; } | ||
|
||
public static List<Order> GetAllRecords() | ||
{ | ||
return new List<Order> | ||
{ | ||
new Order { OrderID = 1001, CustomerID = "ALFKI", Rating = 3 }, | ||
new Order { OrderID = 1002, CustomerID = "ANATR", Rating = 5 }, | ||
new Order { OrderID = 1003, CustomerID = "ANTON", Rating = 2 }, | ||
new Order { OrderID = 1004, CustomerID = "AROUT", Rating = 4 }, | ||
new Order { OrderID = 1005, CustomerID = "BERGS", Rating = 1 }, | ||
new Order { OrderID = 1006, CustomerID = "BLAUS", Rating = 5 }, | ||
new Order { OrderID = 1007, CustomerID = "BLONP", Rating = 3 }, | ||
new Order { OrderID = 1008, CustomerID = "BOLID", Rating = 2 }, | ||
new Order { OrderID = 1009, CustomerID = "BONAP", Rating = 4 }, | ||
new Order { OrderID = 1010, CustomerID = "BOTTM", Rating = 3 }, | ||
new Order { OrderID = 1011, CustomerID = "BSBEV", Rating = 5 }, | ||
new Order { OrderID = 1012, CustomerID = "CACTU", Rating = 1 }, | ||
new Order { OrderID = 1013, CustomerID = "CENTC", Rating = 4 } | ||
}; | ||
} | ||
} | ||
|
||
{% endhighlight %} | ||
{% endtabs %} | ||
|
||
{% previewsample "https://blazorplayground.syncfusion.com/embed/LZLeXzrApyBafWHl?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.