i have two vertex which i will group it.\nwhen ever i click on the grouped(on any one) vertex it should highlight the group not the vertex.\ncan u please share how to do it.

asked 27 Jul '11, 00:53

Dhanrajb's gravatar image

accept rate: 5%

There are various ways of doing this depending on the exact requirements. A simple way of doing this using a click handler is as follows:

graph.addListener(mxEvent.CLICK, function(sender, evt)\n{\n  var e = evt.getProperty('event'); // mouse event\n  var cell = evt.getProperty('cell'); // cell may be null\n\n  if (cell != null)\n  {\n    var parent = this.getModel().getParent(cell);\n\n    if (this.getModel().isVertex(parent))\n    {\n      graph.setSelectionCell(parent);\n    }\n\n    evt.consume();\n  }\n});\n

answered 27 Jul '11, 10:32

Gaudenz's gravatar image

accept rate: 39%

For anyone else who is having this problem ... My application is mxGraph based on the grapheditor example. I've hacked it quite a bit, so it isn't easy to track updates they may make to the example. I was having this problem with groups not selecting the group, and I tracked it down to this routine in Graph.js:

// Disable drilling into non-swimlanes.
this.isValidRoot = function(cell) {
    return this.isValidDropTarget(cell);

changed to

// Disable drilling into non-swimlanes.
this.isValidRoot = function(cell) {
    return this.isSwimlane(cell);

If you're doing this, you may also be interested that where isValidRoot is called in Editor.js, in several places, it is in a while() condition and is proceeded by the term (model.isVertex(parent)) || model.isEdge(parent)). This term changed to simply model.isVertex(parent). I'm not sure why, but I took the change on principle.


answered 10 Feb '13, 15:24

lannie's gravatar image

accept rate: 22%

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: 27 Jul '11, 00:53

Seen: 1,950 times

Last updated: 10 Feb '13, 15:24