Styling Rows
Rows can be styled by using the
rowStyle and the rowClassName props- the
rowStyleprop can be a styleobjector afunctionthat returns a styleobjectorundefined - the
rowClassNameprop can be astring(the name of a CSS class) or afunctionthat returns astringorundefined
const rowStyle: InfiniteTablePropRowStyle<Employee> = ({
data,
rowInfo,
}: {
data: Partial<Employee> | null;
rowInfo: InfiniteTableRowInfo<Employee>;
}) => {
const salary = data?.salary ?? 0;
if (salary > 150_000) {
return { background: 'tomato' };
}
if (rowInfo.indexInAll % 10 === 0) {
return { background: 'lightblue', color: 'black' };
}
return undefined;
};The
rowClassName function prop has the same signature as the rowStyle function prop.The rows are rendered by the grid, not by the template of your component, so the styles of your component - which Angular scopes to its own template - don't reach them. Define the classes you return from
rowClassName in a global stylesheet (src/styles.css), or in a component with encapsulation: ViewEncapsulation.None.Row styling example#
loading demo…
In the
rowStyle function, you can access the rowInfo object, which contains information about the current row. It's especially useful when you have grouping and aggregation, as it contains the aggregation values and other extra info.