Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

listview section is not loading on first time

$
0
0

Hi all,

i am using the below code to show the contents in list view,

Function : on click of a icon, web service is called and the response from web service is loaded to the list view section, the problem here is on click of first time the list view page is shown with empty and only when we go back and click again , the list is shown in the list view.

function loadServices(arr, idToMatch) { 
    Ti.API.info('+++++++++View my services myRequestDetails'+ JSON.stringify(arr));
    for (var j = 0; j < arr.length; j++) {
 
        var lstSection = Ti.UI.createListSection();
        var headerView = Ti.UI.createView({
            height : 60,
            width : "100%",
            backgroundColor : "transparent",
            //lSection : lstSection,
            isExpanded : false,
            lIndex : j
        });
        lstSection.headerView = headerView;
 
        var view = Ti.UI.createView({
            height : 45,
            //width : "100%",
            left : 30,
            right : 30,
            top : 0,
            //lSection : lstSection,
            isExpanded : false,
            backgroundImage : Alloy.Globals.path.imgNormalRow,
            lIndex : j
        });
        headerView.add(view);
 
        var labelSectionTitle = Ti.UI.createLabel({
            left : 30,
            right : 30,
            backgroundColor : "transparent",
            height : Titanium.UI.SIZE,
            touchEnabled : false,
            color : Alloy.Globals.path.whiteColor,
            font : Alloy.Globals.path.font14,
            text :   arr[j].requestNo,  //arr.funerals[j].name,
            textAlign : Titanium.UI.TEXT_ALIGNMENT_CENTER   
        });
        view.add(labelSectionTitle); 
        Ti.API.info('title list'+ arr[j].requestNo);
 
        var sectionSpace = Ti.UI.createView({
            height : 10,
            width : "100%",
            bottom : 0,
            touchEnabled : false,
            backgroundColor : "transparent"
        });
        headerView.add(sectionSpace);
        view.sectionSpace = sectionSpace;
 
        arrSection.push(lstSection);
        if (arr[j].requestNo == idToMatch){
            view.fireEvent("click");    
        }
 
    }
    //alert("test");  <ListItem info:text="Apple" es_info:text="Manzana" pic:image="/apple.png" />
 
    $.listviewServices.sections = arrSection;
    //Ti.API.info('section count'+ $.listviewServices.sectionCount );
    // $.listviewDepartment.sections[0].setItems(arrData);
 
 
}
exports.loadServices = loadServices;
<Alloy>
    <View id="viewMyRequestList">
        <ListView id="listviewServices" class="listContainerRequest" onItemclick="onItemClick"  defaultItemTemplate="itemTemplateMyrequestDropdown">
            <Templates>
                <Require src="listTemplate/itemTemplate"/>
                <ItemTemplate name="itemButton" id="itemButton"  >
                  <View id="viewItemBtn" >
                   <Button id="btnActionMyRequest" bindId="btnActionMyRequest"  onClick="onActionRequest"></Button> 
                  </View>
                </ItemTemplate>
            </Templates>
            <!-- <ListSection id="listsection"/> -->
        </ListView>
    </View>
</Alloy>
<ItemTemplate name="itemTemplateMyrequestDropdown" id="itemTemplateMyrequestDropdown">
        <View id="viewMyrequestRow" bindId="viewMyrequestRow" layout="vertical">
            <Label id="labelMyRequestTitle" bindId="labelMyRequestTitle"></Label>
 
        </View>
</ItemTemplate>
".listContainerRequest":{
    top : 0, 
    bottom : 0,
    width : "100%",
    //separatorHeight :0,
    separatorColor : "transparent",
    backgroundColor : "transparent"
}
".listContainerRequest[platform=android]": {
    separatorHeight :0
}
".listContainerRequest[platform=ios]": {
    separatorStyle: Titanium.UI.iPhone.ListViewSeparatorStyle.NONE,
}
 
"#itemTemplateMyrequestDropdown":{
    height: 40,
    left : 0,
    right : 0,
    backgroundColor: "#80FFFFFF"
}
 
"#itemTemplateMyrequestDropdown[platform=ios]":{
    selectionStyle: 0
}
 
"#viewMyrequestRow":{
    height : 40,
    width : "100%",
 
    backgroundColor : "#80FFFFFF"
}
"#btnActionMyRequest": {
    width : "48%",
    height : 40,
    borderRadius : 5,
    title : Alloy.Globals.selectedLanguage.submit,
    // backgroundColor : Alloy.Globals.path.titleRedColor,
    backgroundImage : Alloy.Globals.path.btnRed,
    color : Alloy.Globals.path.whiteColor,
    font : Alloy.Globals.path.font15,   
}
 
"#labelMyRequestTitle":{
    top : 0,
    bottom : 0,
    left : 10,
    right : 10,
    font : Alloy.Globals.path.font15,
    color : Alloy.Globals.path.blackColor,
    textAlign : Titanium.UI.TEXT_ALIGNMENT_LEFT 
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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