最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ag grid - How to use agSelectCellEditor with a key value pair? - Stack Overflow

programmeradmin2浏览0评论

I am using AngularJS with the JS version of ag-grid-community. When I go to edit the field, the DDL is not defaulting to the current item? To get a key/value pair to work I had to alter ag-grid-community.js to not throw an error on dataTypeMatcher using skipCheckType.

cellEditorParams.values is an array of { key: ..., name: ...} pairs.

{
    headerName: 'Frequency', field: "Frequency",
    cellEditor: 'agSelectCellEditor',
    singleClickEdit: true,
    cellEditorParams: {
        values: $scope.gridFrequencies,
    },
    valueFormatter: (params) => {
        console.log('valueFormatter', params);
        return params.value?.name ? params.value.name:  $scope.gridFrequencies.find(o => o.key == params.value)?.name;
    },
    valueSetter: params => {
        if (params.newValue) {
            params.data.Frequency = params.newValue.key;
            return true; // indicates that the value was successfully set
        }
        return false; // indicates that the value was not set
    },
    skipCheckType: true,
    tooltipValueGetter: params => {
        return params.data.Frequency;
    }
}

ag-grid-community.js change

发布评论

评论列表(0)

  1. 暂无评论