Book a Demo

Author Topic: How to remove elements?  (Read 3756 times)

Marcos Calleja

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
How to remove elements?
« on: April 22, 2015, 09:59:44 pm »
Hi, I tried to search in the forum but i couldn't find it.

I show a method that taking the parent of the element that you want to delete "parent.Elements.DeleteAt()" and needs the position of the element that you want to remove.

I saw also the property TreePos in the element, and i didn't try yet, but It should be something like take this treePos, get the parent, and do a parent.Elements.DeleteAt(treePos). But Im not even sure of this, so...

Is not a easier way to remove elements using the api?

Thanks a lot for your time :)
« Last Edit: April 22, 2015, 10:01:08 pm by mcalleja »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to remove elements?
« Reply #1 on: April 22, 2015, 10:26:12 pm »
Don't get confused. TreePos is something different. The child-elements are in the Elements set. You need to find the one by comparing the ElementID. Once you know the index you use DeleteAt(index). To get something like "deleteByName" you can write your own wrapper.

q.
« Last Edit: April 22, 2015, 10:27:08 pm by qwerty »

Marcos Calleja

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: How to remove elements?
« Reply #2 on: April 22, 2015, 11:59:36 pm »
So the only way is get the parent, iterate in the elements to find the index of the element you want to delete, and execute DeleteAt().

Thanks a lot :)