dashman
dashman

Reputation: 3018

Nativescript ListView onItemLoading event

I'm using the built-in ListView and have the following setup.

<ListView items="{{ myItems }}" itemLoading="onItemLoading" itemTemplateSelector="onTemplateSelector">
<ListView.itemTemplates>
  <template key="even">
    <Label text="{{ age }}" style.backgroundColor="white" />
  </template>
  <template key="odd">
    <Label text="{{ age }}" style.backgroundColor="gray" />
  </template>
</ListView.itemTemplates>

During the onLoadingEvent - where each item is about to be loaded, I look at the args.view and it's always undefined. I would have expected it to be the full template view structure - depending on what onTemplateSelector returned.

Looking at some more of the documentation and it seems that if it's undefined then you've got to create the entire structure within code.

Did I miss something? If no, then what's the purpose of allowing the template item definitions (e.g. Label in my sample code).

Upvotes: 1

Views: 403

Answers (1)

Robert Laverty
Robert Laverty

Reputation: 186

If you just do

<ListView.itemTemplates> <Label text="{{ age }}" style.backgroundColor="gray" /> </ListView.itemTemplates>

That will work fine. I'm not sure what your <template> element is.

Upvotes: 1

Related Questions