ag-grid-vue:如何检测行点击?
ag-grid-vue: how to detect row click?
我正在效仿here。
一切正常,现在我想检测一行点击并获取事件的数据。
这是我的 App.vue
:
<template>
<ag-grid-vue style="width: 500px; height: 500px;"
class="ag-theme-alpine"
:columnDefs="columnDefs"
:rowData="rowData"
:rowClicked="onRowClicked"
>
</ag-grid-vue>
</template>
<script>
import {AgGridVue} from "ag-grid-vue";
export default {
name: 'App',
data() {
return {
columnDefs: null,
rowData: null
}
},
components: {
AgGridVue
},
methods:{
onRowClicked(params) {
console.log(params);
console.log(params.node.data);
}
},
beforeMount() {
this.columnDefs = [
{headerName: 'Make', field: 'make', sortable: true, filter: true },
{headerName: 'Model', field: 'model', sortable: true, filter: true },
{headerName: 'Price', field: 'price', sortable: true, filter: true }
];
fetch('https://raw.githubusercontent.com/ag-grid/ag-grid/master/grid-packages/ag-grid-docs/src/sample-data/smallRowData.json')
.then(result => result.json())
.then(rowData => this.rowData = rowData);
}
}
</script>
<style>
@import "../node_modules/ag-grid-community/dist/styles/ag-grid.css";
@import "../node_modules/ag-grid-community/dist/styles/ag-theme-alpine.css";
</style>
但是,当我点击一行时,onRowClicked
方法没有被调用。
我在这里缺少什么?
我正在效仿here。
一切正常,现在我想检测一行点击并获取事件的数据。
这是我的 App.vue
:
<template>
<ag-grid-vue style="width: 500px; height: 500px;"
class="ag-theme-alpine"
:columnDefs="columnDefs"
:rowData="rowData"
:rowClicked="onRowClicked"
>
</ag-grid-vue>
</template>
<script>
import {AgGridVue} from "ag-grid-vue";
export default {
name: 'App',
data() {
return {
columnDefs: null,
rowData: null
}
},
components: {
AgGridVue
},
methods:{
onRowClicked(params) {
console.log(params);
console.log(params.node.data);
}
},
beforeMount() {
this.columnDefs = [
{headerName: 'Make', field: 'make', sortable: true, filter: true },
{headerName: 'Model', field: 'model', sortable: true, filter: true },
{headerName: 'Price', field: 'price', sortable: true, filter: true }
];
fetch('https://raw.githubusercontent.com/ag-grid/ag-grid/master/grid-packages/ag-grid-docs/src/sample-data/smallRowData.json')
.then(result => result.json())
.then(rowData => this.rowData = rowData);
}
}
</script>
<style>
@import "../node_modules/ag-grid-community/dist/styles/ag-grid.css";
@import "../node_modules/ag-grid-community/dist/styles/ag-theme-alpine.css";
</style>
但是,当我点击一行时,onRowClicked
方法没有被调用。
我在这里缺少什么?