Unable to remove specified seat

Iam using fallowing statement for removing seat
if i use myDiagram.findNodeForKey(keyId).removeAt(4); its removing the 4 seat
but when i use myDiagram.findNodeForKey(keyId).removeAt(12); its not removing the 12th seat
but It is removing when i use myDiagram.findNodeForKey(keyId).removeAt(6);
could you please tell me how to remove the seats based on the number inside the seat or could you please tell me alternative way to remove the seats from node in gojs seating chart

You need to iterate over the Panel.elements to find the object (seat) that you want to remove. Remember that the first element is the “table”. I guess you’ll want to look at each element’s “name” property.
Then after you find what you want you can call Panel.remove or Panel.removeAt.

Hi Walter
Thanks for your reply i know that iterating the collections but i don’t know how to iterate Panel elements could you please tell me how to get panel from node and how to iterate panel elements

http://gojs.net/latest/intro/collections.html

The Node class inherits from the Part class which inherits from the Panel class.

I am using the fallowing code for iterate the panel elements still my problem is not resolved

for (var it = obj.elements; it.next(); ) {
var elt = it.value;
if (elt.name == 11) {
obj.removeAt(11);
}
}

the above code causes the fallowing error

Uncaught Error: List.elt:i is not in the range 0 <= i < length: 11

Call obj.remove (elt); break;

Thanks for your solution but it will not work when i want to remove seats from 11 to 14 the code i write like this

var i = 11;
for (var it = obj.elements; it.next(); ) {
var elt = it.value;
if (i <= 14) {
if (elt.name == i) {
obj.remove(elt);
}
}
i = i + 1;
}

is it possible to remove seats from 11 to 14?

You can’t modify a collection while iterating over it, and Panel doesn’t provide a method to remove a collection (unlike the Set and List classes), so you’ll need to save the ones that you find and then remove each of them afterwards.

Thanks for your advice…