Hi,\nI need to be able to use several mxDefaultToolbars (via mxDefaultToolbarCodec, that is to have defined them in the config xml), could you tell me how that can be accomplished ?\nI think it would have something to do with the <ui> section, but I do not know how to do it.\nThanks.

asked 22 Aug '11, 03:15

Shockedder's gravatar image

accept rate: 22%

There is no direct support for multiple toolbars in the default setup, but here is what you can do to support any number of toolbars and configure them via the config file.


Step 1 is to create a toolbar for a specific element in the page, say you have a DIV with an ID of toolbar2, then the code for this is as follows:

var container2 = document.getElementById('toolbar2');\nvar toolbar2 = new mxDefaultToolbar(container2, editor);\n

Next step is to make this new toolbar accessible via a field in the editor, so that the I/O system can pick it up and configure it. This is done as follows:

editor.toolbar2 = toolbar2;\n

In the above code the new toolbar would be stored under toolbar2 in the editor instance. Note that this must be done before the editor is cofigured using mxEditor.configure. Now you can refer to the toolbar and configure it in the config file as follows:

<mxEditor>\n  <mxDefaultToolbar as="toolbar2">\n    ...\n

The difference is that you cannot use the UI section to associate the additional toolbar with the element in the page. This is done programmatically as shown above.


answered 23 Aug '11, 04:21

Gaudenz's gravatar image

accept rate: 39%

Yes, that's exactly what I ended up doing.Mercifully, the programatic toolbar is static. The gain on the codec side (ie xml) is that you can swap them before runtime or change them on the fly due to the structured content of the xml.\nThanks.

(23 Aug '11, 06:25) Shockedder
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 22 Aug '11, 03:15

Seen: 1,871 times

Last updated: 23 Aug '11, 06:25