-
Notifications
You must be signed in to change notification settings - Fork 161
Conditional Grid Row Cell Styling
Version | User | Date | Notes |
---|---|---|---|
0.1 | Zdravko Kolev | 12 Aug, 2021 | Initial draft |
- Radoslav Karaivanov | Date:
- Desislava Dincheva | Date:
igx-grid
is a component used to display tabular data in a series of rows and columns. These rows and columns provide the ability of conditional styling based on certain criteria - cell value, row index and etc.
Provide means for the developers to implement a simple common case, yet customizable cell/row styles with minimal effort.
- As a developer, I want to add a style with a Grid Input (data row styling) and Column Input (cell styling).
Column input for cellClasses:
<igx-column field="BeatsPerMinute" dataType="number" [cellClasses]="beatsPerMinuteClasses"></igx-column>
Grid input for rowClasses:
<igx-grid [rowClasses]="beatsPerMinuteClasses"></igx-grid>
- As a developer, I want to be able to define a cell style based on a condition that will return a boolean value that determines whether to apply a certain class or not ('downFont' and 'upFont' being the CSS classes)
public beatsPerMinuteClasses = {
downFont: this.downFontCondition,
upFont: this.upFontCondition
};
- As a developer, I want to be able to define a cell style based on a condition that will return a style definition as object literal. Each of the object properties should be relevant to CSS properties (e.g.):
public styles = {
"background": "linear-gradient(180deg, #dd4c4c 0%, firebrick 100%)",
"text-shadow": "1px 1px 2px rgba(25,25,25,.25)",
"animation": "0.25s ease-in-out forwards alternate popin"
};
-
As a developer, I want to be able to define a data row style based on a condition that will return a boolean value that determines whether to apply a certain class or not ('downFont' and 'upFont' being the CSS classes)
-
As a developer, I want to be able to define a data row style based on a condition that will return a style definition as object literal. Each of the object properties should be relevant to CSS properties (e.g.):
As an end user, I want to have different data rows/cells styles in my Grid, so that I could be presented with different visual details and distinguish any visual elements in aesthetic way.
The developer can add different cell/data row styles through:
- Object literal containing key-value pairs. The key is the name of the CSS class, while the value is either a callback function that returns a boolean, or boolean value.
- Object literal where the keys are style properties and the values are expressions for evaluation.
- When it comes to applying styles to a row we consider only the data rows. Currently the summary rows, group by rows and etc. could not be styled with
rowClasses
androwStyles
.
The grid introduces the following input properties:
-
cellClasses
- used in Column input -
cellStyles
- used as Column input -
rowClasses
- used in Grid input -
rowStyles
- used as Grid input
-
cellClasses
androwClasses
binding should be used to add and remove CSS class names from the cell/data row element's class attribute. -
cellClasses
androwClasses
- accepts an object literal containing key-value pairs. The key is the name of the CSS class, the value is either a callback function that returns a boolean or boolean value. -
cellStyles
androwStyles
binding should be used to set styles on the grid's cell/data row element dynamically. -
cellStyles
androwStyles
- accepts an object literal where the keys are style properties and the values are expressions for evaluation. Should be able to apply regular styling without any conditions. - The callback signature for both
cellStyles
andcellClasses
is:
(rowData: any, columnKey: string, cellValue: any, rowIndex: number) => boolean
- The callback signature for both
rowClasses
androwStyles
will be:
(row: RowType) => boolean
- With the new row styling functionality both
evenRowCSS
andoddRowCSS
will be deprecated.
- Shoud be able to conditionally style rows. Check is the class present in the cell/row native element class list.
- Should apply custom CSS bindings to the grid cells/rows. Check the style attribute to match each binding:
const styles = {
background: 'black',
color: 'white'
};
- Should have correct cell/row classes after horizontal/vertical scroll