Comments (7)
You can already do that, just not directly in the parameter (example comes from the demosite):
@inject DataSource Data
<FluentDataGrid Items="@Data.People" style="width: 600px;">
<TemplateColumn Title="Person" SortBy="@sortByName">
<div class="flex items-center">
<img class="flag" src="_content/FluentUI.Demo.Shared/flags/@(context.CountryCode.ToLower()).svg" alt="Flag of @(context.CountryCode)" />
<nobr>
<strong>@context.LastName</strong>, @context.FirstName
</nobr>
</div>
</TemplateColumn>
<TemplateColumn Title="Bonus">
<FluentButton Appearance="Appearance.Accent" @onclick="@(() => Bonus(context))">Regular</FluentButton>
<FluentButton Appearance="Appearance.Accent" @onclick="@(() => DoubleBonus(context))">Double</FluentButton>
</TemplateColumn>
</FluentDataGrid>
<p><strong>@message</strong></p>
@code {
string message = string.Empty;
GridSort<Person> sortByName = GridSort<Person>
.ByAscending(p => p.LastName)
.ThenAscending(p => p.FirstName);
void Bonus(Person p) => message = $"You want to give {p.FirstName} {p.LastName} a regular bonus";
void DoubleBonus(Person p) => message = $"You want to give {p.FirstName} {p.LastName} a double bonus";
}
What are you missing?
from fluentui-blazor.
My situation is the TemplateColumn created by foreach loop, it's dynamically created. Each TemplateColumn has different parameter for sorting. For example, we have dynamic object, the properties is not known until runtime, I need to pass each property to specific TemplateColumn for sorting, same as to have DataGrid context of List of key-value Dictionary.
from fluentui-blazor.
I think you can do that with a method that returns a GridSort result. You kan use the @key as a parameter for that method.
from fluentui-blazor.
I think you can do that with a method that returns a GridSort result. You kan use the @key as a parameter for that method.
The TemplateColumn has no onClick event before sort, cannot pass the current @key to the method which return GridSort.
from fluentui-blazor.
The @key
comes from the foreach
loop in your example. Passing that to a method does exactly the same as using the inline variant that you are suggesting
from fluentui-blazor.
The
@key
comes from theforeach
loop in your example. Passing that to a method does exactly the same as using the inline variant that you are suggesting
Thanks. It works.
I have another question, when I add sortBy, the header row will add button, how to change the background-color of the button?
The XPath:
//*[@id="fdb48c27"]/fluent-data-grid/fluent-data-grid-row[1]/fluent-data-grid-cell[2]/fluent-button//button
The button is a shadow element, cannot easy to add css style for it.
from fluentui-blazor.
This is possible but goes directly against the purpose of this library: supplying components leveraging the Fluent UI design system.
You can target the component with CSS by using the ::deep
selector and then specifying which part of the shadow DOM you want to target by using the standard ::part
selector. Something like:
::deep > fluent-button::part(control){
...your css...
}
Closing this as the original issue is not an issue and provided guidance works.
from fluentui-blazor.
Related Issues (20)
- fix: FluentEditForm fields are non editable when wrapped in FluentTab and using version 4.7.2 HOT 5
- feat: add ability to turn off SelectAll button in SelectColumn Multiple mode HOT 2
- fix: initial ActiveIndicator in FluentTabs HOT 2
- fix: Double click needed for expanding/collapsing child elements in FluentNavGroup when prerendering is turned off HOT 2
- feat: add support for BackgroundColor & Color in FluentAnchor HOT 1
- fix: bind-SelectedOption is null when using bind-SelectedOption:after FluentComboBox
- feat: add support for Virtualize for FluentCombobox HOT 7
- docs: fix/add Toast / Custom component example / Razor code HOT 2
- Add CultureInfo.InvariantCulture to ToString("0.00") HOT 1
- fix: clicking ColumnOptions in FluentDataGrid throws exception HOT 2
- docs: Make Aside (In this article) scrollable
- docs: add documentation on how to provide more parameters to custom dialogs HOT 5
- feat: add OnKeyUp in FluentKeyCode HOT 1
- docs: add some guidance to configure RTL mode HOT 1
- feat: add multi-column to/in combobox HOT 2
- feat: add [required] to [Label] HOT 3
- Maximum call stack size exceeded when using FluentDesignSystemProvider and a FluentCard HOT 2
- feat: [DataGrid] Deselect all other items when row is clicked (not checkbox) HOT 4
- FluentCheckbox issue HOT 1
- Tree component HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fluentui-blazor.