Hi,

\n

the current implementation of mxGraph.prototype.setCellWarning will remove all overlays when the cell becomes valid. The guilty line is 15402: this.removeCellOverlays(cell);

\n

I overrided the function to fix this in such a way:

\n

mxGraph.prototype.setCellWarning = function (cell, warning, img, isSelect) {\n if (warning != null && warning.length > 0) {\n img = (img != null) ? img : this.warningImage;\n var overlay = new mxCellOverlay(img, '<font color=red>' + warning + '</font>');\n if (isSelect) {\n overlay.addListener(mxEvent.CLICK, mxUtils.bind(this, function (sender, evt) {\n if (this.isEnabled()) {\n this.setSelectionCell(cell);\n }\n }));\n }\n return this.addCellOverlay(cell, overlay);\n } else {\n var overlays = this.getCellOverlays(cell);\n if(overlays){\n var indexes = new Array();\n for(var i = 0; i < overlays.length; i++){\n if(overlays[i].image.src.indexOf("warning.gif") != -1){\n indexes.push(i);\n }\n }\n for(var i = 0; i < indexes.length; i++){\n this.removeCellOverlay(cell, overlays[indexes[i]]);\n }\n }\n }\n return null;\n};

\n

My question is: Is there a better way to determine which overlays are warning ones? I check the image source but I don't know if this will not change in future releases.

\n

Regards,

\n

Martin

asked 13 Sep '11, 00:49

mrtndimitrov's gravatar image

mrtndimitrov
9110
accept rate: 0%


The generic image source may be obtained from graph.warningImage.src.

link

answered 13 Sep '11, 02:11

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

Thanks. So, determining the type of the overlay based on the image is OK?

(13 Sep '11, 04:14) mrtndimitrov

Yeah, the validation methods only create overlays with those images, so if you don't use the same it should be fine.

(13 Sep '11, 04:41) Gaudenz
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×10
×8

Asked: 13 Sep '11, 00:49

Seen: 1,460 times

Last updated: 13 Sep '11, 04:41