Global Toolbar Settings

Is there a way to globally default the [allToolbarsInMyApp].setIconSize(24); for an entire application? I don’t want to have to do this for literally 1000s of toolbars. Thank you.

Hopefully support will have a answer…

In the meantime I thought I would share a possible solution. This works well because there are oftentimes you want to set the icon path too:

dhtmlXLayoutObject.prototype.attachTB=function() {
  var tb = this.attachToolbar();
  tb.setIconsPath( myTbPath );
  return tb

And then use it as a replacement for attachMyToolbar():

  var layout = new dhtmlXLayoutObject(document.body, '2U');
  var tb      = layout.attachTB();

There is no native approach. We just can suggest something similar.

OK, I see where you are going, but that only works when attaching to a layout. I don’t want to have to define every combination/scenario. I need the same “global” functionality for all DHTMLX items. I don’t want to have to write prototypes for EVERY item that EVERY item can attach to. Isn’t there a way to just override the grid/toolbar/etc… “init” function? That way no matter what I attach a grid/toolbar/etc… to it will get the same global code ran.


There is not a single common method to set every toolbar to a particular size (which is fine by my standards–do you REALLY want 24px toolbars all over the page?)

Anyway, I use a variation of this to for attaching the tb to cell:

dhtmlXLayoutObject.prototype.attachToolbarCell=function(cell) {
  var tb = this.cells(cell).attachToolbar();
  tb.setIconsPath(  'myPath' );
  return tb

Between these 2 prototypes it covers all of my needs.

Here’s the places where you can attach a toolbar:

layout cell

So there would only be 2 more prototypes to write.

Or create a single generic function…something like:

function toolbarAttach(obj) {
  var tb = obj.attachToolbar();
  tb.setIconsPath(  'myPath' );
  return tb