Dynamically change layout cell header

Is there a way to dynamically change a layout cell’s header? I’m creating a layout, but I want to do an ajax call to get the environment (test, production, etc) and indicate it in a cell header at the top of my page. I don’t want to rework the whole page to have it wait for the AJAX call to return before doing the rest of the work to load the page.

Ideally, I’m looking for something as simple as a layout.getCell(“myCell”).setHeader(“New Header Text”); But if there’s another way to accomplish it I can go that route.

Hi
I do as follows to change the header:
layout.getCell('toolbar').config.header = "new header";

Here’s an example:

https://snippet.dhtmlx.com/dltbr4dz

I hope it helps, greetings.

1 Like

complementing my answer. @sematik, I would like to leave a suggestion for implementing a method or way to update the header, and also be able to insert html elements, currently it is only possible to insert text.

Another thing is to leave the addCell() method in an official way, its use is very practical.

Thanks for the tip! It didn’t work straight for me out of the box as you showed, but then I realized that you’re causing a display change of the cell and it may be getting picked up in that. My cell isn’t changing anything about the display, so I had to do this after:
layout.getCell('toolbar').paint()

That got the header displaying as I wanted.

1 Like

Another solution depending on how you want your layout to look is to not use a header at all but use another cell instead.
I’m using a 4C layout with cell B (the top horizontal cell) as the header set to about 40px high.
This way I can use attachHTML() and put what ever I want in there.

But yes you should always repaint your layout or toolbar in your case.

1 Like

I would like to leave a suggestion for implementing a method or way to update the header, and also be able to insert html elements, currently it is only possible to insert text.

Thank you for your request. I’ve sent it to the dev team and it will be observed, so the possible solution may appear in the future updates.

to leave the addCell() method in an official way, its use is very practical.

We already removed the addCell() method from the documentation:

Its usage is pretty limited. We also are not planning to add it back again.