Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Global or Extensible ListView Templates?

$
0
0

Does anyone have a methodology of establishing a global set of ListView templates, so that a specifically referenced template by a ListItem won't need to find a localized template within the current controller?

Or alternatively, is there a way to extend the current controllers available templates by importing/requiring a shared/commonjs resource of ListView templates that could be used throughout an app?

The end goal is to be able to have reusable templates through out an app without having to recreate them for every controller's view xml.

Additionally, being that templates are defined on a per-ListView level, rather than on a per-ListSection level, there doesnt seem to be an available means to require independent ListSections into a central ListView without losing their associated templates.

For example, there is no way to have controller-specific templates for sec1.xml and sec2.xml that inherit into index.xml, without specifying each section's templates within index.xml. This makes the section controllers styles non-transferable to other controllers, needing to be redefined in each controller they want to be used in.

index.xml

<Alloy>
    <ListView>
        <Require src="sec1" />
        <Require src="sec2" />
    </ListView>
</Alloy>
sec1.xml
<Alloy>
    <ListSection>
        <ListItem title="one" />
        <ListItem title="two" />
    </ListSection>
</Alloy>
sec2.xml
<Alloy>
    <ListSection>
        <ListItem title="A" />
        <ListItem title="B" />
    </ListSection>
</Alloy>
Furthermore the following does not seem possible, as a work around to create a sharable template set:

index.xml

<Alloy>
    <ListView>
        <Require src="templates" />
        <Require src="sec1" />
        <Require src="sec2" />
    </ListView>
</Alloy>
templates.xml
<Alloy>
    <Templates>
        <ItemTemplate name="template1" >
            <Label bindId="title" />
        </ItemTemplate>
        <ItemTemplate name="template2" >
            <Label bindId="header" />
            <ImageView bindId="icon" />
        </ItemTemplate>
    </Templates>
</Alloy>
Does anyone have any ideas on how to make templates sharable/global within the Alloy MVC architecture?

Viewing all articles
Browse latest Browse all 8068

Trending Articles