We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to avoid length node names when repeatedly copy/pasting same node

Thread ID:

Created:

Updated:

Platform:

Replies:

127810 Dec 9,2016 02:43 PM Dec 11,2016 11:51 PM JavaScript 1
loading
Tags: ejDiagram
Jim Jacobs
Asked On December 9, 2016 02:43 PM

Hi,

Today, if a user copies and pastes the same node several times, we can end up with names like this:

TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgS
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0T
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMw
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMwkO75
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMwkO75vZZE
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMwkO75vZZEvr5A

Ideally I would like the pasted node to have a net new name rather than simply appending a new random string to the existing name (although the base name from the palette must be at the beginning - e.g., Task in the above samples).

I looked at the documentation and noticed that the paste method accepts 2 arguments:

paste([object], [rename])

However, I don't always have an object - in fact we have a clone function that copies ALL nodes on a diagram and pastes them on a new diagram. I was hoping I could do something like diagram.paste(,true) or diagram.paste(true) since object is optional, but that doesn't paste anything.

Any suggestions on how to avoid these lengthy names?

Thanks

Jim




Kameshwaran R [Syncfusion]
Replied On December 11, 2016 11:51 PM

Hi Jim, 
 
Hi,

Today, if a user copies and pastes the same node several times, we can end up with names like this:

TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgS
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0T
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMw
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMwkO75
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMwkO75vZZE
TaskSUVHcHPwiimioCiWMQ0DvZUEBrE1EAddPTHRVyIkwqJ80CgSGH0TZXq7IDMwkO75vZZEvr5A

Ideally I would like the pasted node to have a net new name rather than simply appending a new random string to the existing name (although the base name from the palette must be at the beginning - e.g., Task in the above samples).
 
Please use the following code snippet to achieve your requirement. 
 
 
nodeCollectionChange: function (args) { 
    if (args.cause === "clipBoard") { 
        args.cancel = true; 
        var diagram = $("#diagram").ejDiagram("instance"); 
        var node = args.element; 
        node.name = ej.datavisualization.Diagram.Util.randomId(); 
        console.log(node.name); 
        diagram.add(node); 
    } 
} 
I looked at the documentation and noticed that the paste method accepts 2 arguments:

paste([object], [rename])

However, I don't always have an object - in fact we have a clone function that copies ALL nodes on a diagram and pastes them on a new diagram. I was hoping I could do something like diagram.paste(,true) or diagram.paste(true) since object is optional, but that doesn't paste anything.
 
 
Currently we don’t have option to pass the null or undefined as first argument of the paste method, Since the diagram.paste method renders only the object passed as first argument. So only the paste method doesn’t paste anything if we passed empty object as first object. 
 
 
Regards, 
Kameshwaran R. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;