效果如下:
<gf-grid :filterRemote="false" ref="elecGrid" class="elec-grid drag-column"
style="z-index: 3;"
:class="isBizDate ? 'isBizDate': ''"
height="100%"
grid-no="agnes-elec-process-field"
:options="elecGridOptions(this)"
:onDataLoaded="onDataLoaded"
@SelectionChanged="onSelectionChanged"
></gf-grid>
在data的变量里找到elecGridOptions的配置项里添加 rowClassRules,渲染项,代码如下:
elecGridOptions: (_that)=>{
return {
onRowDataChanged: (params) => {
params.columnApi.columnController.autoSizeAllColumns();
if(_that.elecGridSelected){
this.$nextTick(()=>{
const selectIndex = _that.elecGridSelected.childIndex;
params.api.ensureIndexVisible(selectIndex, 'middle');
params.api.selectIndex(selectIndex);
})
}
},
onSelectionChanged: (params)=>{
_that.elecGridSelected = params.api.getSelectedNodes()[0];
_that.elecGridSelectedNodes = params.api.getSelectedNodes()
},
onCellClicked(params) {
// 定义可以被点击的单元格
const showDetailArr = ['baseId']
if (showDetailArr.includes(params.colDef.field)) {
_that.shows(params)
}
},
rowClassRules: {
'ag-row-selected': (params) => {
console.log("this.stepExcecId",params.data.stepExecId, _that.stepExecId);
if(params.data.stepExecId === _that.stepExecId){
params.node.setSelected(true);
return true;
}
}
}
}