-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose itemTemplateSelector
for the ListView
ns-core Layout
#957
Comments
This should already work iirc |
I have created this small demo clean app to try out on it. Outputs an error and crashes on both iOS and Android. I have tried to search for this error, but I couldn't find a reasonable answer. I have checked the @ns/core module packages But I couldn't manage to do it. |
Same here I'm using NativeScript 7.3.0 but I can't seem to get it to work. Documentation seems lacking with regards to this subject. I've based my code on examples using vanilla NativeScript and NativeScript Angular but my code resulted in:
I've been trying to find an example of how it should be used with NativeScript Vue but no luck so far. |
I've investigated a bit and to me there seems to be a bug in the
If I'm understanding the code correctly here in line 27 it's always the This will break <template>
<GridLayout class="list-wrapper">
<ListView class="list"
:items="dataList"
:itemTemplateSelector="selector"
>
<v-template name="fruit">
<Label :text="`Sweat ${item.name}`" />
</v-template>
<v-template name="veggies">
<Label :text="item.name" />
</v-template>
</ListView>
</GridLayout>
</template> This won't break, but only default template will be used <template>
<GridLayout class="list-wrapper">
<ListView class="list"
:items="dataList"
:itemTemplateSelector="selector"
>
<!-- Set template to "default" or else don't set a name,
which internally will set template name to "default" -->
<v-template name="default">
<Label :text="`Sweat ${item.name}`" />
</v-template>
<v-template name="veggies">
<Label :text="item.name" />
</v-template>
</ListView>
</GridLayout>
</template> |
So what if we want to have templates branching within the list, so we might add the default for fallbacks, but still need the other ones to show based on the item selector. |
@adel12790 I've managed to find out how to make it work. It's listed in the documentation and I think last time I missed it. So you have to use the Using the same example as above you can have something like so: <template>
<GridLayout class="list-wrapper">
<ListView class="list" for="item in dataList">
<v-template if="item.type === 'fruit'">
<Label :text="`Sweat ${item.name}`" />
</v-template>
<v-template if="item.type === 'veggies'">
<Label :text="item.name" />
</v-template>
</ListView>
</GridLayout>
</template> According to the documentation in the |
What problem does this feature solve?
It will have better performance when it comes to loading huge lists, as the item selector will fetch and feed the views that only map the selector criteria.
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: