Handling parent element directives on custom directive


#1

Considering the following XML, how can I handle the col and row directives on the CustomSearchBar directive so that the GirdLayout will still place it in the right col/row with out wrapping it in a StackLayout for example?

Doesn’t work:

<GridLayout rows="auto" columns="auto *">
  <CustomSearchBar col="0" row="0"></CustomSearchBar>
  <Button col="1" row="0" text="foo"></Button>
</GridLayout>

Does work:

<GridLayout rows="auto" columns="auto *">
  <StackLayout col="0" row="0">
    <CustomSearchBar></CustomSearchBar>
  </StackLayout>
  <Button col="1" row="0" text="foo"></Button>
</GridLayout>

#2

I have little angular knowledge, but using the col and row in NS, seems strange you can’t set those on the component. If it’s a NS view you should be able to set it and everything work. Which may help some in figuring this out. Your source for the CustomSearchBar might help some. Never tried anything like this but seems possible.


#3

@abhayastudios - maybe this gives some insight into what you’re after also http://forum.nativescript.org/t/have-to-nest-custom-views-to-work-in-container-views/386


#4

@bradwaynemartin, I missed your post somehow. Indeed this seems to be an open issue.

I’ll just continue to wrap it in a StackLayout for now!

Thanks a lot!