0

我可以显示 Range.width 但我想以这种格式显示内容:宽度 x 高度:100 x 100

这有效:

{ id:"Range", name:"Fixed Range", field: "Range.width", formatter: Formatters.complexObject, sortable: true, filterable: true, minWidth: 100, },

但它只显示宽度,我想同时显示宽度和高度。

在此处输入图像描述

这是数据的样子:

"Range": {
        "width": 2,
        "height": 2
    },

我的目标是在列中显示这样的数据: 在此处输入图像描述

4

1 回答 1

0

我使用以下方法解决了这个问题:

 RangeFormatter(row, cell, value, columnDef, dataContext) {
    return dataContext.Range.width? ( dataContext.Range.width + " x " + dataContext.Range.height) : "<span style='color: red;'>" + "x" + "</span>";
}

/* Define grid Options and Columns */
defineMotionDevicesGrid() {
    this.columnDefinitionsMotionDevices = [
        { id: "HardwareId", name: "Hardware Id", field: "HardwareId", sortable: true, filterable: true, minWidth: 100, },
        { id: "Range", name: "Fixed Range (Width x Height)", field: "Range", selectable: false, formatter: this.RangeFormatter, sortable: true, filterable: true, minWidth: 100, },
             
    ];
}
于 2021-02-12T10:47:58.750 回答