Grid Component : Conditional css class for grid row #248
-
Based on my own testing, Conditional css class only works if I'm using standard Bootstrap color classes like table-danger, table-primary etc. I want to use my own CSS class for colors not available in Bootstrap. How can I accomplish this task? If you can provide sample code, that would be good. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
@joselitogatchalianalonzo Thanks for trying |
Beta Was this translation helpful? Give feedback.
-
Thanks @gvreddy04 I'll just wait for the sample code. |
Beta Was this translation helpful? Give feedback.
-
Default Example: https://demos.blazorbootstrap.com/grid#conditional-css-class-for-grid-row Now, add the below custom CSS class to your .css file: .table-row-yellow {
--bs-table-color: #000;
--bs-table-bg: #F8D81D;
--bs-table-border-color: #DFC32A;
--bs-table-striped-bg: #ECCD89;
--bs-table-striped-color: #004;
--bs-table-active-bg: #DFC364;
--bs-table-active-color: #000;
--bs-table-hover-bg: #E5C865;
--bs-table-hover-color: #000;
color: var(--bs-table-color);
border-color: var(--bs-table-border-color);
} Update the private string GetRowClass(Employee1 emp)
{
if (!emp.IsActive)
return "table-row-yellow"; // custom CSS class
else if (emp.Designation == "Architect")
return "table-success";
return string.Empty;
} Note:
|
Beta Was this translation helpful? Give feedback.
-
Thanks @gvreddy04. I will try the sample code. |
Beta Was this translation helpful? Give feedback.
Default Example: https://demos.blazorbootstrap.com/grid#conditional-css-class-for-grid-row
Now, add the below custom CSS class to your .css file:
Update the
GetRowClass(.....)
method with the new custom CSS class.