use Map() to handle renderers
This commit is contained in:
parent
e8e3a4c793
commit
dcb7d02a5f
2 changed files with 5 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
import { booleanRenderer } from "./customRenderer"
|
import { booleanRenderer } from "./customRenderer"
|
||||||
|
|
||||||
const setters = new Map([["number", number]])
|
const setters = new Map([["number", number]])
|
||||||
|
const renderers = new Map([["boolean", booleanRenderer]])
|
||||||
|
|
||||||
import fetchData from "../fetchData.js"
|
import fetchData from "../fetchData.js"
|
||||||
import { isEmpty } from "lodash/fp"
|
import { isEmpty } from "lodash/fp"
|
||||||
|
@ -36,8 +37,7 @@
|
||||||
hide: shouldHideField(key),
|
hide: shouldHideField(key),
|
||||||
sortable: true,
|
sortable: true,
|
||||||
editable: schema[key].type !== "boolean",
|
editable: schema[key].type !== "boolean",
|
||||||
cellRenderer:
|
cellRenderer: renderers.get(schema[key].type),
|
||||||
schema[key].type === "boolean" ? booleanRenderer : null,
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// Custom renderers to handle special types
|
||||||
|
// https://www.ag-grid.com/javascript-grid-cell-rendering-components/
|
||||||
|
|
||||||
export const booleanRenderer = (params) => {
|
export const booleanRenderer = (params) => {
|
||||||
const toggle = (e) => {
|
const toggle = (e) => {
|
||||||
params.value = !params.value
|
params.value = !params.value
|
||||||
|
|
Loading…
Reference in a new issue