Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (template)
Viewing all articles
Browse latest Browse all 26

How to add nested childTemplates inside listView??

$
0
0

Hi everyone.. I have code like this:

var listViewRowTemplate = {
        properties: {
            height: '100dp'
        },
        childTemplates: [
            {
                //lblIndicator
                type: 'Ti.UI.Label',
                bindId:'lblIndicator',
                properties: {}
            },
            {
                //lblCustomer
                type: 'Ti.UI.Label',
                bindId:'lblCustomer',
                properties: {}
            },
            {
                //menu View
                type: 'Ti.UI.View',
                bindId:'menuView',
                properties: {},
                childTemplates: [
                    {
                        //lblName
                        type: 'Ti.UI.Label',
                        bindId:'lblName',
                        properties: {}
                    }
                ]
            }
        ]
    };
 
    var section = Ti.UI.createListSection({});
    var listView = Ti.UI.createListView({
        top:'175dp',
        height:Ti.UI.FILL,
        templates: { 'listViewRowTemplate': listViewRowTemplate },
        sections: [ section ]
    });
and i fill that listView with this code:
var listViewRow;
 
                listViewRow = {
                    template:'listViewRowTemplate',
                    properties:{backgroundColor:'green'},
                    _data:myData,
                    lblIndicator:_globals.get('combine')(_styles.get('label.normal'), {
                        _id:'indicator',
                        left:'10dp',
                        backgroundImage:bgIndicator,
                        backgroundSelectedImage:bgIndicatorHover,
                        height:'40dp',
                        width:'40dp',
                        top:'5dp'
                    }),
                    lblCustomer:_globals.get('combine')(_styles.get('label.normal'), {
                        _id:'customer',
                        text:myData[i].CustomerShortDesc,
                        left:'50dp',
                        top:'0dp',
                        height:'50dp'
                    }),
                    menuView:_globals.get('combine')(_styles.get('view.tableview.header'), {
                        _id:'menu',
                        left:'10dp',
                        height:'40dp',
                        width:_globals.get('app.platformWidth') * 0.7,
                        top:'50dp',
                        lblName:_globals.get('combine')(_styles.get('label.normal'), {
                            _id:'name',
                            left:'10dp',
                            text:'This is for name',
                            color:'red',
                            height:'40dp',
                            width:'40dp',
                            top:'5dp'
                        })
                    })
                };
 
                listViewData.push(listViewRow);
 
                section.setItems(listViewData);
For your info, _globals.get() and _styles.get() is my own custom JS file that return properties or object.

i can see my other component like lblIndicator, lblCustomer, and menuView, but not my nested component (lblName)..

Does anyone know how to fill listview with a nested component (childTemplates inside childTemplates)? Please give me some suggestion.. Many thanks..


Viewing all articles
Browse latest Browse all 26

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>