更改所选行的颜色

时间:2017-10-31 08:42:30

标签: angular ag-grid

你能告诉我,我在哪里可以找到财产来源(比如在事件onRowClicked上的参数), 如果我将属性命名为onRowSelected。我需要通过复选框更改我单击的行的颜色 enter image description here

grid = {
        columnDefs: [],
        rowSelection: 'multiple',
        rowData: null,
        rowGroupPanelShow: 'always',
        getRowStyle: function (params) {                
            //some code for changing background-color
        },
        onSelectionChanged: rowSelectionChanged,
        onRowDoubleClicked: onRowDoubleClicked,
        groupSelectsChildren: false,
        onRowClicked: clickFunction,
        suppressRowClickSelection: true,
        onRowSelected: selectionChangedFunc,
        onGridReady: function() {
            this.api.hideOverlay();
        }
    };
    function selectionChangedFunc(params){
            console.log(params)    
    }

    function clickFunction(params){
            console.log(params)   
    }

1 个答案:

答案 0 :(得分:1)

只需使用突出显示项目的索引

<div *ngFor="let row of rows;let i=idx" 
    (click)="selectedRow = i"
    [class.highlighted]="i == selectedRow">{{row.data}}<div>