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.

Undo Question - How to find actual deletedItems, not just their names

Thread ID:

Created:

Updated:

Platform:

Replies:

129954 Apr 11,2017 12:18 PM Apr 13,2017 05:11 AM JavaScript 3
loading
Tags: ejDiagram
Jim Jacobs
Asked On April 11, 2017 12:18 PM

Hi,

I'm starting to play with Undo/Redo again and have a question.
If I select multiple nodes and click on delete, in my historychange event handler I see the following:

args
  > changes
    > 0
      > deletedItems
        > 0
          > _type  "pseudoGroup"
          > children
            0   "TaskQTqu"
            1   "Data-StorewrAU"
            2   "InterProcessRtfo"

I have also attached a screenshot showing a slightly different, but similar, scenario.
Where can I find the actual nodes that are being deleted?
I need to interrogate various addInfo properties of these nodes.
Using diagram.getNode("TaskQTqu") does not return the node (since it's no longer on the diagram).

Obviously the node info is stored somewhere since I am able to Undo the delete and the addInfo properties are restored.

How can I locate the node info?

Thanks

Jim





Attachment: Undo__deletedItems_for_selection__05apr2017_bea7ec41.zip

Shyam G [Syncfusion]
Replied On April 12, 2017 08:50 AM

Hi Jim, 
 
Please use nodeCollectionChange event to achieve your requirement. While performing undo operation, the nodeCollectionChange event triggers if an collection is modified. In this event, you can get an objects which is inserted or deleted.  
 
Code example: 
//define nodecollectionchange event 
DiagramContent.OnClientNodeCollectionChange = "nodeCollectionChange"; 
 
function nodeCollectionChange(args){             
                //we get an object only if a cause is historyChange 
            if (args.state === "changing" && args.cause === "historyChange") {                  
                //get an element 
                var node = args.element; 
                  
            } 
        } 
 
Regards, 
Shyam G 


Jim Jacobs
Replied On April 12, 2017 03:15 PM

User Action
nodecollectionchange cause
nodecollectionchange changeType
historychange cause
What to do?
Drop new node
drop
insert
undefined
Add new node to database
Undo drop
unknown
remove
undo
Remove node from database
Redo drop
historychange
insert
redo
Add node to db with previous properties
Delete the node
unknown
remove
undefined
Remove node from database
Undo delete
historychange
insert
undo
Add node to db with previous properties
Redo delete
unknown
remove
redo
Remove node from database

Shyam,

Thanks for the tip.

It seems that if the nodecollectionchange changeType is remove, I cannot rely on the nodecollectionchange cause to determine if an undo or redo was just performed.

Instead I'm setting a global variable in the historychange event to indicate this action.

Is this correct?    Should the nodecollectionchange cause not be "historychange" if I do a redo?

Comments?

Thanks

Jim





Shyam G [Syncfusion]
Replied On April 13, 2017 05:11 AM

Hi Jim, 
 
We considered this “Need to update missing cause in the nodeCollectionChange and historyChange event” as an issue and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates. 
 
 
Regards, 
Shyam G 


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.

;