| Article | 70001177 |
| Type | HowTo |
| Product | WebJS |
| Date Added | 9/29/2017 12:00:00 AM |
| Fixed | 7.7012.0.7 (9/29/2017 12:00:00 AM) |
| 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();
