I am trying to create a custom cell renderer to dynamically add multiple colored badges horizontally to a single Ag Grid cell with props
input from my dash app in the form [('text', 'A'), ('other text', 'B'), ...]
. I tried to return a [badge, badge, …] array from my js but that failed, and I also tried wrapping the badges in a single dmc.Group
element to be returned (see below), but that also failed. Unfortunately I don’t have much js experience! Any thoughts?
var dagcomponentfuncs = window.dashAgGridComponentFunctions = window.dashAgGridComponentFunctions || {};
dagcomponentfuncs.Mult_Badges = function (props) {
const badges = [];
for (let i = 0; i < props.length; i++) {
if (props.value[i][1] == 'A') {
badge_clr = 'blue';
} else if (props.value[i][1] == 'B') {
badge_clr = 'red';
} else {
badge_clr = 'green';
}
badge = React.createElement(
window.dash_mantine_components.Badge,
{
color: badge_clr,
},
props.value[i][0]
);
badges.push(badge);
};
return = React.createElement(
window.dash_mantine_components.Group,
{
},
badges
);
};