NS ListView issues with itemTemplates (NS 2.5.3)


I’m trying to use the ListView itemTemplates feature with item-template-selector.

 <ListView items="{{ myItems }}" itemTemplateSelector="myFunction">
  <template key="green">
    <Label text="{{ age }}" style.backgroundColor="green" />
  <template key="red">
    <Button text="{{ age }}" style.backgroundColor="red" />

Two issues:

  1. I described the full xml definition for each template. But when the onItemLoading() event is called for the first time, the args.view value is always undefined. Does that need to be created all the time? If so, then what’s the purpose of requiring the definition in xml (the Label/Button above).

  2. A more serious issue. I’ve implemented the selection of the template in a callback method. And initially I create a list of key GREEN. As noted in previous point, I created the template programmatically and works.

Then on a tap-event, I insert 1 row of key RED between first and second items. Now when the onItemLoading of key RED is called, the args.view is already set to the view created for GREEN - which is a Label instead of a Button.

I understand listview is trying to cache the views, but should it not cache the views based on the template selector key?

If the list-item is of key RED, it should get it from a cached list of just RED keys. In this case since it’s not there - view.args should be undefined and that forces the ui to create a new one.

It really doesn’t any sense to set view of a given template to that of another template key. Can’t be used anyway.

I hope I’ve explained this - I’d be happy to give more detail if there’s interest.

As is, this itemTemplates feature is severely hobbled - but I see great potential and would like to use it.

Caching based on template key would also make useful and much faster.