Closed BozzaDaniel closed 9 months ago
Since version 14.1.9 setting a custom itemTemplateSelector no longer works.
The following works in 14.1.8, but not in 14.1.9 or later:
<template> <Pager for="item in items" :itemTemplateSelector="templateSelector"> <v-template name="template-1"> <GridLayout> <Label text="template 1" /> </GridLayout> </v-template> <v-template name="template-2"> <GridLayout> <Label text="template 2" /> </GridLayout> </v-template> </Pager> </template> <script lang="ts"> import Vue from 'vue' export default Vue.extend({ data() { return { items: ['template-1', 'template-2'] } }, methods: { templateSelector(item) { return item } } }) </script>
The error logged in the console is the following:
System.err: Calling js method onCreateViewHolder failed System.err: Error: Expecting a valid View instance. System.err: System.err: StackTrace: System.err: _addView(file: app/webpack:/app/node_modules/@nativescript/core/ui/core/view-base/index.js:531:0) System.err: at PagerRecyclerAdapterImpl.onCreateViewHolder(file: app/webpack:/app/node_modules/@nativescript-community/ui-pager/index.android.js:674:0)
There is a workaround to get a custom itemTemplateSelector working, by changing type to always be 0. The correct template is still selected. https://github.com/nativescript-community/ui-pager/blob/056199593f4cac453370acf3ba6b2c7503a4f0e8/src/ui-pager/index.android.ts#L752
Anything @BozzaDaniel ? @farfromrefug
@BozzaDaniel @liamcharmer should be fixed in 14.1.18
@farfromrefug works perfect!!!!
Since version 14.1.9 setting a custom itemTemplateSelector no longer works.
The following works in 14.1.8, but not in 14.1.9 or later:
The error logged in the console is the following:
There is a workaround to get a custom itemTemplateSelector working, by changing type to always be 0. The correct template is still selected. https://github.com/nativescript-community/ui-pager/blob/056199593f4cac453370acf3ba6b2c7503a4f0e8/src/ui-pager/index.android.ts#L752