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. Image for the cookie policy date

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

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

3 Replies

SG Shyam G Syncfusion Team April 12, 2017 12:50 PM UTC

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 



JJ Jim Jacobs April 12, 2017 07:15 PM UTC

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






SG Shyam G Syncfusion Team April 13, 2017 09:11 AM UTC

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 


Loader.
Up arrow icon