Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5386] IOS: insertRowAfter method is not working for tableViewSection in tableView

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2019-04-04T18:04:07.000+0000
Affected Version/sRelease 1.7.2, Release 1.8.0, Release 2.1.0, Release 3.2.0, Release 3.2.1
Fix Version/sn/a
ComponentsiOS
Labelsapi, reprod
ReporterFrancisco Antonio Duran Ramirez
AssigneeAlan Hutton
Created2011-09-28T16:39:51.000+0000
Updated2019-04-04T18:04:07.000+0000

Description

Problem

If you add four rows to the first section of a table view, sometimes on the simulator,ipod, or ipad 1 & 2 appear different in the sections of a tableview. If you add only two rows everything is fine, when adding four new rows two are added to the correct section, the other two to the following.

Reproducible steps:

1.Run the code below. Following should now happen: If you click the first "Show all" row (First section, first row), then rows with News 1.1 huhuhuhu, News1.2 will be appended in the first section and 1.3 & 1.4 will be new first rows in the second section. If you do the same with the second section, then everything will be alright, because only two addional rows will be appended.

Expected behavior

Customer wants to add four rows to the first section of the table view.

Sample Code:


//Here's the first window...
var first = Ti.UI.createWindow({
  backgroundColor:"#fff",
  title:"My App"
});


/*Some data*/
var myData = [[
[{
    "group": "Aktuelles",
    "headline": "News1.1 hip hip hurra",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ... LAST",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Aktuelles",
    "headline": "News1.2 bl bla",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Aktuelles",
    "headline": "News1.3",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Aktuelles",
    "headline": "News1.4",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},
{
    "group": "Aktuelles",
    "headline": "News1.1 huhuhuhu",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...Some more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ...ome more text about ... LAST",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Aktuelles",
    "headline": "News1.2",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Aktuelles",
    "headline": "News1.3",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Aktuelles",
    "headline": "News1.4",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
}
],
[{
    "group": "Fach",
    "headline": "News2.1",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Fach",
    "headline": "News2.2",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Fach",
    "headline": "News2.3",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Fach",
    "headline": "News2.4",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Fach",
    "headline": "News2.3",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Fach",
    "headline": "News2.4",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
}
],[{
    "group": "Sonstiges",
    "headline": "News3.1",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Sonstiges",
    "headline": "News3.2",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Sonstiges",
    "headline": "News3.3",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
},{
    "group": "Sonstiges",
    "headline": "News3.4",
    "teaser": "Teaser for News...",
    "content": "Some more text about ...",
    "leftImage": "images/newsPlaceholder.png",
    "image": "images/newsPlaceholder.png",
    "type": "news"
}
]
]
]
yh = {};
yh.ui = {};

yh.ui.createOverviewData = function(_data){
        var tVdata = [];
        for(var group in _data){
            var tVG = Ti.UI.createTableViewSection({
                headerTitle: _data[group][0].group,
                _groupID: group
            })
            var _gData = _data[group].slice(0,4);

            if(_data[group].length > 4){
                var allEntries = Ti.UI.createTableViewRow({
                    backgroundColor: '#fc0000',
                    color: '#fff',
                    className: "allEntries",
                    hasDetail: true,
                    title: "Show all"
                });
                tVG.add(allEntries);
            }

            var tRows = yh.ui.createOverviewRows(_gData,0);
            for(var r in tRows){
                tVG.add(tRows[r]);
            }
            tVdata.push(tVG);
        }

        return tVdata;
    };

    yh.ui.createOverviewRows = function(_data,_indexInt){
        var rows = [];
        for(var entry in _data){
            var tVR = Ti.UI.createTableViewRow({
                className: "overviewRow",
                hasChild: true,
                height: 55,
                _id: Number(_indexInt)+Number(entry),
                indentionLevel: 1,
                layout: 'vertical',
                leftImage: _data[entry].leftImage,
                dataType: _data[entry].type
            });

            var hl = Ti.UI.createLabel({
                font: {fontSize: 14, fontWeight: 'bold'},
                height: 15,
                left: 70,
                text: _data[entry].headline,
                top: 2
            });
            var ct = Ti.UI.createLabel({
                bottom: 0,
                font: {fontSize:12,fontWeight: 'normal'},
                height: 30,
                left: 70,
                text: _data[entry].teaser
            });
//          Ti.API.info(hl);
            tVR.add(hl);
            tVR.add(ct);
            rows.push(tVR);
        }
        return rows;
    }


yh.ui.createOverviewList = function(_data){
        var tVdata = yh.ui.createOverviewData(_data);
        var tV = Ti.UI.createTableView({
            data: tVdata,
            editable: false,
            left: 0,
            style: Ti.UI.iPhone.TableViewStyle.GROUPED
        });

        tV.addEventListener('click',function(e){
            if(e.source.className == 'allEntries'){

                var nData = _data[e.section._groupID].slice(4);
                var r = yh.ui.createOverviewRows(nData);
                var p = e.index+(e.section.rowCount-1);
                var j = 0;
                for(var j in r){
                    var index = Number(p)+Number(j);
                    tV.insertRowAfter(index,r[j]);
                    if(j == r.length-1){
                        tV.deleteRow(e.index);
                    }
                }
            }else{
                // Some other code to display a detail view.
            }
        })

        return tV;
    };
first.add(yh.ui.createOverviewList(myData[0]));
first.open();


Associated HD Ticket:

APP-388641

Attachments

FileDateSize
Ipad 1 & 2.jpg2011-09-28T16:39:51.000+00001516949
Ipod Touch.jpg2011-09-28T16:39:51.000+00001856504
Simulator.png2011-09-28T16:39:51.000+0000143393

Comments

  1. Junaid Younus 2012-07-12

    Tested on the iOS simulator with 2.1GA, issue still reproducible.
  2. Neeraj Gupta 2012-07-12

    Subject line of this ticket is poorly written as it does not provide any meaningful information.
  3. Lee Morris 2017-05-26

    I have been able to reproduce this issue with the following environment; iPhone 7 (10.2) MacOS 10.11.6 (15G31) Studio 4.9.0.201705021158 Ti SDK 6.1.0.v20170519131839 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.7.0_80
  4. Alan Hutton 2019-04-04

    Was unable to reproduce the issue with : MacOS 10.14.4 Ti SDK 8.0.0 GA Appc CLI 7.0.10 Ti CLI 5.1.1 Xcode 10.2 Node 8.11.3 Java 10.0.2_13

JSON Source