简体   繁体   中英

Dynamic header name refresh with Ag-Grid

I have a "select" column and I want to have the total of the current selected rows in the header name.

I am using headerValueGetter but the value is not refreshed when a new row is selected.

// in my colDef
headerValueGetter: params => `(${this.totalSelected})`

// methods
onSelectionChanged(event) {
  this.totalSelected = event.api.getSelectedNodes().length
},

totalSelected is a property of my Vue component and its value is updated when a new row is selected.

Any ideas how to accomplish this ?

在此处输入图片说明

Try refreshing the header manually in your selectionChanged-event:

onSelectionChanged(event) {
  this.totalSelected = event.api.getSelectedNodes().length;
  gridOption.api.refreshHeader();
},

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM