我尝试使用用户定义的行ID来防止重新呈现,而不是Vue ag-grid文档中描述的应用程序分配的ID。但是,唯一的行ID未分配给行,未调用回调getRowId,它将行ID添加为0、1、2......。根据文档,不清楚在哪个时间点调用回调函数来分配用户提供的行ID。
我用“vue”:“^2.6.11”和“@ag-grid-community/vue”:“^26.1.0”
型号
<template>
<div>
<template>
<ag-grid-vue
style="height: calc(100vh - 148px)"
class="ag-theme-balham"
:columnDefs="columnDefs"
@grid-ready="onGridReady"
:rowData="rowData"
:getRowId="getRowId"
></ag-grid-vue>
</template>
</div>
</template>
脚本
<script>
export default {
name: "My-Component",
data() {
return {
columnDefs: [
{ headerName: "Row ID", valueGetter: "node.id" },
{ field: "id" },
{ field: "make" },
{ field: "model" },
{ field: "price" },
],
gridApi: null,
columnApi: null,
rowData: null,
getRowId: null,
};
},
created() {
this.rowData = [
{ id: "c1", make: "Lima", model: "Celica", price: 35000 },
{ id: "c2", make: "Ford", model: "Mondeo", price: 32000 },
{ id: "c8", make: "Porsche", model: "Boxster", price: 72000 },
{ id: "c4", make: "BMW", model: "M50", price: 60000 },
{ id: "c14", make: "Aston Martin", model: "DBX", price: 190000 },
];
this.getRowId = (params) => {
return params?.data.id;
};
},
};
</script>
1条答案
按热度按时间uubf1zoe1#
我想你没有把ag-drid文档看清楚。
enter image description here