70001177 How to clear all the deleted items

Article 70001177
Type HowTo
Product WebJS
Version 7
Date Added 9/29/2017
Fixed 7.7012.0.7 (9/29/2017)
Submitted by Brendan Fry

Summary

How can i clear all the deleted items from the collection

Solution

Please check the following code:

 var vdcanvas = vdmanager.AttachCanvas('canvas');
 var tempCol = [];
 var activelayout = vdcanvas.GetActiveLayout();
 for (var k = 0; k < activelayout.Entities.Items.length; k++) {
       var fig = vdcanvas.GetEntityItem(activelayout.Entities.Items[k]);
       if (!fig.Deleted) tempCol.push(activelayout.Entities.Items[k]);
 }
 activelayout.Entities.Items = tempCol; 
Note that if you clear the deleted items you will not be able to use undo/redo for these items, so when you clear the deleted items you can also clear the undo history like: vdcanvas.UndoHistory().Clear();

Send comments on this topic.