I want to change label of element


#1

25

I tried to use the modelig.updateProperties function, but I can not use it because the xml has been changed.
So when I changed the text using the style, the same thing happened.
I do not want xml to change, but I want the label to change visually.


#2

Please give more context. What exactly are you trying to achieve?

What do you mean by


#3

I originally intended to do this,

modeling.updateProperties(shape,{name: 'aa'});

This way has a problem that the xml data is also modified.
So I do not do this way.

 var graphics = $(modeler.get('elementRegistry').getGraphics(element));
                        graphics
  graphics.find('.djs-visual > text > tspan').text('aa');

The problem with this way is that the x and y values ​​applied to the tags are not appropriate,
So it is not centered and it is displayed at a strange position.

I hope the two conditions are satisfied.

want to Change the label of the element,

Hopefully the xml data will not change and the labels will be centered. only change visually


#4

The whole point of using updateProperties or any method that modifies the model is that the XML that represents the model will reflect these changes.

What is you use case?


#5

I wish xml did not change

So now I can not use that function(updateProperties)

I just want it to be seen in different texts.


#6

What’s the point of the rendered text not reflecting the name of an element?


#7

I am doing multilingual processing now,
and I want to have the basic language stored in the xml information and
to reflect the multilingual language at the time of drawing.
so i do not want xml to be modified,


#8

How do you want to handle translation? Do you want to store translations in the XML, in a seperate file or do it on the fly using a web service?


#9

I have the translated data.

so, So it’s a good to know how to process with the above problems in the modeler and viewer.


#10

in viewer,

can i delay shape.render ??

I get the data from the server asynchronously,
I want to change the label of the element again based on it.
However, since the data is not received and render is performed, the desired label is not output.
and the default label is output, then it is replaced by the value received from the server.

So, for example,
It turns out that the change from ‘a’ to ‘b’ is problematic on visual.


Delay the rendering of element
#11

You can postpone the diagram import until you retrieved the translations. For rendering the translated labels without changing the underlying model you can modify the renderer to look up the translation when rendering a label.


#12

how to postpone rendering??

Please explain with specific code.


#13

What I mean is simply not starting the import until you have the data. Call importXML once you’re ready.


#14

If i defer importXml, i will not be able to know the information contained in each element.
i must call the server’s api with the value contained in each element(Received via xml).


#15

You can also separate generating the model and importing and retrieve the data in between.


#16

how to separate??
Do you have sample code?


#17

First you parse the XML using bpmn-moddle, then you can call Viewer#importDefinitions directly.