【问题标题】:How to add columns: edit, delete?如何添加列:编辑、删除?
【发布时间】:2019-08-21 05:05:21
【问题描述】:

我想使用 vue ag-grid。所以我查看了Get Started with ag-Grid in Your Vue Project 文章。

但我找不到任何关于如何将delete 列添加为链接按钮的示例?

<a :click="handleDelete">delete</a>

handleDelete(itemData) {
 // should open popup here base on itemData…
}

这是我正在使用的代码:

<template>
    <ag-grid-vue style="width: 500px; height: 500px;"
                 class="ag-theme-balham"
                 :columnDefs="columnDefs"
                 :rowData="rowData">
    </ag-grid-vue>
</template>

    this.columnDefs = [
                {headerName: 'Make', field: 'make'},
                {headerName: 'Model', field: 'model'},
                {headerName: 'Price', field: 'price'}
            ];

            this.rowData = [
                {make: 'Toyota', model: 'Celica', price: 35000},
                {make: 'Ford', model: 'Mondeo', price: 32000},
                {make: 'Porsche', model: 'Boxter', price: 72000}
            ];

【问题讨论】:

    标签: vue.js ag-grid


    【解决方案1】:

    您需要为自定义列定义cellRendererFramework,如下所示:

    this.columnDefs = [
      { headerName: 'Make', field: 'make' },
      { headerName: 'Model', field: 'model' },
      { headerName: 'Price', field: 'price' },
      { headerName: 'Delete', cellRendererFramework: 'DeleteCell' }
    ];
    

    还要确保您注册了您的 DeleteCell 组件:

    components: {
      AgGridVue,
      DeleteCell,
    },
    

    【讨论】:

    • 以及如何从 DeleteCell 组件中获取当前字段?
    猜你喜欢
    • 2018-08-03
    • 2014-06-02
    • 1970-01-01
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    相关资源
    最近更新 更多