Skip to content
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

Feat/row class name #1031

Merged

Conversation

mostrowski123
Copy link
Contributor

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

#1025

💡 Background and solution

There currently is no way of conditionally applying styles to rows in a table. This is useful if you want to highlight a row conditionally based on the row data.
I fixed this by adding a Func<RowData<TItem>, string> RowClassName parameter to the table component and queried its value in the class attribute where rows are created.
Screen Shot 2021-01-22 at 3 28 18 PM

📝 Changelog

I should note there is an issue when hovering on the highlighted rows as the hover color overrides the any color set by the custom style. I am not sure if this is acceptable or not, but I was unable to find a way to darken the color that is set. My apologies.

Language Changelog
🇺🇸 English add RowClassName attribute to table component
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

@mostrowski123
Copy link
Contributor Author

This is my first ever PR so my apologies for any mistakes or errors. I tried to follow the guidelines provided to the best of my ability.

@codecov-io
Copy link

codecov-io commented Jan 22, 2021

Codecov Report

Merging #1031 (93d0850) into master (bc062f4) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1031      +/-   ##
=========================================
- Coverage    5.49%   5.49%   -0.01%     
=========================================
  Files         424     426       +2     
  Lines       23095   23128      +33     
=========================================
  Hits         1270    1270              
- Misses      21825   21858      +33     
Impacted Files Coverage Δ
components/table/Table.razor 0.00% <0.00%> (ø)
components/table/Table.razor.cs 0.00% <0.00%> (ø)
components/card/Card.razor 0.00% <0.00%> (ø)
components/card/Card.razor.cs 0.00% <0.00%> (ø)
components/card/CardAction.razor.cs 0.00% <0.00%> (ø)
components/card/CardAction.razor 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc062f4...93d0850. Read the comment docs.

@ElderJames
Copy link
Member

Thank you for you contribution @mostrowski123

It's very nice.

@@ -184,7 +184,7 @@ RenderFragment<(Table<TItem> table, bool header)> colGroup = ctx =>
}
@if (!hasChildren && table.ExpandTemplate != null && table.RowExpandable(currentRowData))
{
<tr class="ant-table-expanded-row ant-table-expanded-row-level-1" style="@(currentRowData.Expanded?"":"display: none;")">
<tr class="ant-table-expanded-row ant-table-expanded-row-level-1 @table.RowClassName(currentRowData)" style="@(currentRowData.Expanded?"":"display: none;")">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an other peroperty for expand row.

image

@ElderJames ElderJames linked an issue Jan 24, 2021 that may be closed by this pull request
@ElderJames ElderJames merged commit 9fb9bff into ant-design-blazor:master Jan 24, 2021
ElderJames added a commit that referenced this pull request Apr 23, 2022
* feat(module: table): add row styling

* docs: add RowClassName to docs

* docs: add custom row style subtext

* feat(module: table): add ExpandedRowClassName

* remove RowClassName for expand row

* add chinese doc

Co-authored-by: ElderJames <shunjiey@hotmail.com>
ElderJames added a commit that referenced this pull request Apr 30, 2022
* feat(module: table): add row styling

* docs: add RowClassName to docs

* docs: add custom row style subtext

* feat(module: table): add ExpandedRowClassName

* remove RowClassName for expand row

* add chinese doc

Co-authored-by: ElderJames <shunjiey@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conditionally style rows in a table
3 participants