View Full Version : Ext.form.Panel: query vs. remove methods

3 Oct 2016, 7:43 AM
First, I'm using ExtJs version 4.2.2.

I have a panel and I call .query() on it, it finds the value that I'm querying for. However, if I then call .remove() on the panel, it doesn't find the item to remove, and therefore returns undefined.


What's going on, and how should I be handling this in my code? Is there a better way to remove the item?


3 Oct 2016, 12:48 PM
Remove only removes direct children, so you need to call remove on the direct parent of the thing you want to remove.

3 Oct 2016, 1:31 PM
Thanks for the response. So, the query method queries all children?

To remove a nested child, I should do something like this?

parentPanel.items.items[0].remove(item, false);

3 Oct 2016, 2:03 PM
If you just want it to be destroyed, then just call item.destroy(). Otherwise, it would be simpler to use item.ownerCt.remove(item, false);

3 Oct 2016, 2:42 PM
Perfect. That makes so much sense. I'm just new to ExtJs and have no clue what I'm doing. Appreciate the help!