We’re trying to replace some standard HTML tables in our Dash app with Dash AG Grid. One thing I want to have in each row is a dropdown menu of links.
I am aware of the rowMenu cell renderer, but it has a few deficiencies for my use case:
- doesn’t appear to support customizing the button appearance. I would like to have standard bootstrap dropdown button appearance with an icon and text instead of the generic + svg that DAG uses
- doesn’t appear to support rich formatting within the menu itself (only a text label and associated value). Maybe I could use a callback to make this work but since these are external links that should open in a new tab, I’d rather not do that unless there is no other alternative.
Here is a picture of what I am trying to achieve (the way a menu looks in our current HTML table using DBC DropDownMenu):
I’ve started writing a custom cell renderer to try to do this, but I’m getting stuck.
This is what I have so far:
const iconText = (icon, text, children) => {
return React.createElement(
'div',
null,
React.createElement(
'i',
{ class: 'me-1 ' + icon },
),
text,
children
);
}
dagcomponentfuncs.DropdownLinks = function (props) {
return React.createElement(
'div',
{ className: 'dropdown show' },
React.createElement(
'button',
{
className: "me-1 btn btn-primary btn-sm",
},
iconText("bi-link-45deg", "Links ", React.createElement(
'i',
{ className: 'me-1 bi bi-caret-down-fill' },
)),
),
React.createElement(
'div',
{ className: "dropdown-menu show" },
props.value.map(([icon, title, url]) =>
React.createElement(
'a',
{ href: url },
iconText(icon, title)
)
)
)
)
};
This doesn’t implement the logic to toggle the dropdown menu currently but I was going to try to just get it to show properly and then figure out the toggling. I noted that for a DBC DropdownMenu, when I toggle the menu, “show” gets added to the CSS class, so that is what I have tried to do above to make it visible, but it’s not showing up.
As you can see in this screenshot, it’s positioning the dropdown correctly but it seems to be invisible or behind the AG Grid. (Note: I have removed the URLs from the a href elements in the inspector screenshot but they are correctly populated.
Any suggestions, please?