diff --git a/docs/assets/tips.md_ignore b/docs/assets/tips.md_ignore index b0b6d5a004e..cd5180afec5 100644 --- a/docs/assets/tips.md_ignore +++ b/docs/assets/tips.md_ignore @@ -1940,4 +1940,88 @@ const App = () => ( ); export default App; -``` \ No newline at end of file +``` + +--- + +By using `` or ``, you can easily customize the cell style in the `columnDefs` definition using `cellStyle`: + +{% raw %} +```jsx +const columnDefs = [ + // same style for each row + { + field: 'static', + cellStyle: {color: 'red', 'background-color': 'green'} + }, + // different styles for each row + { + field: 'dynamic', + cellStyle: params => { + if (params.value === 'Police') { + //mark police cells as red + return {color: 'red', backgroundColor: 'green'}; + } + return null; + } + }, +]; +``` +{% endraw %} + +https://www.ag-grid.com/react-data-grid/cell-styles/#cell-style + +--- + +Similar to what you can do with ``, you can also use [the CSS API](https://marmelab.com/react-admin/Datagrid.html#sx-css-api) to style your `` or your ``. + +{% raw %} +```tsx + +``` +{% endraw %} + +https://www.ag-grid.com/react-data-grid/cell-styles/#first--last-columns + +--- + +You can add custom CSS classes to any column or cell in `DatagridAG` or `DatagridAGClient`, using the `cellClass` or `cellClassRules` keys of `columnDefs`: + +{% raw %} +```tsx +const columnDefs = [ + { field: 'static', cellClass: 'my-class' }, + { field: 'staticArray', cellClass: ['my-class1','my-class2'] }, + { field: 'function', cellClass: params => params.value === 'something' ? 'my-class-1' : 'my-class-2' }, + { field: 'functionArray', cellClass: params => ['my-class-1','my-class-2'] }, + { + field: 'functionRules', + cellClassRules: { + 'rag-green-outer': params => params.value === 2008, + 'rag-blue-outer': params => params.value === 2004, + 'rag-red-outer': params => params.value === 2000, + } + }, + { + field: 'simplifiedFunctionRules', + cellClassRules: { + 'rag-green': 'x < 20', + 'rag-blue': 'x >= 20 && x < 25', + 'rag-red': 'x >= 25', + } + } +]; +``` +{% endraw %} + +https://www.ag-grid.com/react-data-grid/cell-styles \ No newline at end of file