
# Datagrid 行样式
- **rowStyler**: 自定义行样式函数，返回类型 
```javascript
{
    style?: { [key: string]: string }, 
    cls?: string
}

```

# 示例

```html
<farris-datagrid
    [fit]="true" [pagination]="false"
    [virtualized]="false"
    [fitColumns]="true" [columns]="columns" [data]="items"
    
    [rowStyler]="rowStyle" >
</farris-datagrid>
```

```javascript
import { Component, OnInit } from '@angular/core';
import { CalculationType } from '@farris/ui-datagrid';
import { DemoDataService } from '../../demo-data.service';
import { DemoDataSeed } from '../../demo-data-seed';

@Component({
    selector: 'demo-row-formatter',
    templateUrl: './demo-row-style.component.html',
    providers: [
        DemoDataService
    ]
})
export class DemoRowStylerComponent implements OnInit {
    columns = [];
    items;

    fitColumns = true;

    constructor(private dds: DemoDataService) { }

    ngOnInit(): void {

        const enumData = DemoDataSeed.enumData();
        const enumOpts = { valueField: 'value', textField: 'label', data: enumData };

        this.columns = [
            { field: 'id', width: 100, title: 'ID'},
            { field: 'name', width: 130, title: '姓名'},
            { field: 'sex', width: 70, title: '性别' },
            { field: 'birthday', width: 120, title: '出生日期'},
            { field: 'maray', width: 70, title: '婚否', formatter: { type: 'boolean', options: { trueText: '已婚', falseText: '未婚' }}},
            { field: 'addr', width: 170, title: '地址' },
            { field: 'company', width: 100, title: '公司'},
            { field: 'nianxin', width: 70, title: '年薪', footer: {
                options: { calculationType: CalculationType.sum},
                formatter: { type: 'number', options: { prefix: '￥', suffix: '元', precision: 2 }}
            }},
            { field: 'zhiwei', width: 100, title: '职位', formatter: {type: 'enum', options: enumOpts} }
        ];

        this.items = this.dds.createData(50);
    }

    rowStyle = (rowData) => {
        if (rowData.nianxin > 70000 && rowData.nianxin < 100000) {
            return {
                style: {
                    color: '#5A8129',
                    background: '#CCE7A4'
                }
            };
        } else {
            return {
                cls: 'custom-row-style'
            };
        }
    }
}


```