[TIMOB-14795] TiAPI: Add "parent" property for all Ti.UI.View subclasses
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-11-15T05:03:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.0.0 |
Components | TiAPI |
Labels | parent, view |
Reporter | Fokke Zandbergen |
Assignee | Hans Knöchel |
Created | 2013-07-21T18:42:40.000+0000 |
Updated | 2017-11-15T05:03:39.000+0000 |
Description
Only via Q&A I discovered I can use
.parent
and .getParent()
to get the parent of any view. This is extremely useful in many cases.
Is there are reason for not documenting these? Is it not stable or going to be deprecated soon for another reason?
If not, please document it :)
Talked with development. This property is not meant to be exposed as a public API. Tested on iOS and Android and the behavior is different.
So, why not make it behave the same? Being able to get the parent of an element can be quite useful? Should I open another ticket to request the feature to be made solid and public?
Hi [~fokke], I moved the ticket over to TIMOB as a new feature request. Could you please provide an explanation of why you want this feature and the expected behavior for the development team? Thanks.
The expected behavior is for
view.parent
andview.getParent()
to return the parent view.An example use case is removing a view in an Alloy controller. Without
.parent
I need to assign anid
to the parent view. With, I can just do$.myView.parent.remove($.myView);
Which makes me think another method that might make sense would be:removeFromParent()
, basically doing the above?We should add this. It makes tons of sense. Mobile Web had this.
+1 this is basic functionality
+1 This should be a fundamental option. Like a lot of other things in Ti, basic UI often seems neglected. As Fokke comments it can be useful, because otherwise one has to always pass references to the parent view into the controller in question.
We will do it. And if there are parity-gaps, we should discuss them in this ticket. I tested it with iOS and it works just as expected, going directly from the managed view-proxy. I am wondering how Android could behave different here (maybe [~gmathews] has some input here). Also, does Windows support this, [~kiguchi]? Making this for 7.0.0 should be doable, let me know your thoughts! :-) *EDIT*: Tested with Android and it works just fine as well. Let's do this! *EDIT 2*: [This branch](https://github.com/appcelerator/titanium_mobile/compare/master...hansemannn:TIMOB-14795?expand=1) is waiting to be PR'd once we have a decision.
Yes!
[~hknoechel]
View.parent
property andget/setParent
functions are already supported on Windows. We also have unit tests: [ti.ui.view.test.js#L452](https://github.com/appcelerator/titanium_mobile_windows/blob/master/Examples/NMocha/src/Assets/ti.ui.view.test.js#L452)Great! Than we should add more unit-tests to the PR and merge it in I guess.
Assigning to Gary to clarify how Android handles this. As iOS and Windows do handle it already, we may close this if Android passes as well.
Android also has this implemented, here's a quick test case. The one above is incorrect:
We only need to add
parent
to our docsI verified the test case on Android; per comments, I'll close the ticket.