jgraph / mxgraph

mxGraph is a fully client side JavaScript diagramming library
Other
6.82k stars 2.06k forks source link

How to add customized and complex template on the left sidebar #442

Closed litaotao closed 4 years ago

litaotao commented 4 years ago

Hi, MXGRAPH Team

First I've to thanks a lot for building such an awesome project, it's one of the most fantastic open source project in my experience.

Now I'm wondering using MXGRAPH in my project, here I have one problem and get no answer after digging into the source code, hope someone can give me some hints.

problem

I want to know how to add customized and complex template on the left sidebar. For example, bellow is a table template from the official:

截屏2020-03-18下午9 48 27

code is bellow:

this.createVertexTemplateEntry('text;html=1;strokeColor=#c0c0c0;fillColor=#ffffff;overflow=fill;rounded=0;', 280, 160,
      '<table border="1" width="100%" height="100%" cellpadding="4" style="width:100%;height:100%;border-collapse:collapse;">' +
      '<tr style="background-color:#A7C942;color:#ffffff;border:1px solid #98bf21;"><th align="left">Title 1</th><th align="left">Title 2</th><th align="left">Title 3</th></tr>' +
      '<tr style="border:1px solid #98bf21;"><td>Value 1</td><td>Value 2</td><td>Value 3</td></tr>' +
      '<tr style="background-color:#EAF2D3;border:1px solid #98bf21;"><td>Value 4</td><td>Value 5</td><td>Value 6</td></tr>' +
      '<tr style="border:1px solid #98bf21;"><td>Value 7</td><td>Value 8</td><td>Value 9</td></tr>' +
      '<tr style="background-color:#EAF2D3;border:1px solid #98bf21;"><td>Value 10</td><td>Value 11</td><td>Value 12</td></tr></table>', 'Table 1')

This template looks good, but I want a little different one, I need every "td" in that table is an independent template, and the whole table template is the group of all "td" template.

In Future

If possible, I hope I can add some small templates which are grouped and designed using those basic templates into the left sidebar, I believe that will boost our users' efficiency in a high degree.

Again, thanks a lot for building MXGRAPH.

ajaydhar1 commented 4 years ago

I have the same question!

How can we build templates using the provided shapes and make them available in the sidebar?