ag-grid实时监测复选框变化
监测复选框变化
1.最终效果:
点击复选框,页面显示已选中多少条
2. 实现步骤:
1. 在ag-grid中添加: @selection-changed="onSelectionChanged"
<ag-grid-vue class="table ag-theme-balham" v-show="isSee" id="myGrid" :columnDefs="columnDefs" :rowData="rowData" :sideBar="sideBar" :enableColResize="true" row-selection="multiple" @selection-changed="onSelectionChanged" @gridReady="onGridReady" :tooltipShowDelay="tooltipShowDelay" :localeText="localeText" :height="tableMaxHeight" > </ag-grid-vue>
2. 在methods中添加方法
//监测复选框选中的个数 onSelectionChanged(){ var selRows = this.gridApi.getSelectedRows(); this.selectedData = selRows.length; }
3. 页面显示样式