Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1206] Issue on ListView's marker event

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNot Our Bug
Resolution Date2015-04-10T10:37:19.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsTCSupportTriage
ReporterMauro Piccotti
AssigneeShuo Liang
Created2014-10-15T09:35:00.000+0000
Updated2016-03-08T07:37:35.000+0000

Description

Marker event on ListView component isn't launched when the row on which there is the marker is showed arriving on it not scrolling, but deleting the rows one by one (using the deleteItemsAt() method on the listItem section).

Comments

  1. Shuo Liang 2014-10-16

    Hi, Would you please provide us a test case to reproduce your problem, that will be really helpful. Thanks. Regard, Shuo
  2. Mauro Piccotti 2014-10-16

    You are right, but it's a little complex to create a working example extracting it from my software, I'll try as I'll find time. Have you ever heard about this problem? Does it have sense in your opinion? Because I thought that the marker event probably works only scrolling the list, and in my case I don't scroll.
  3. Mauro Piccotti 2014-10-30

    I try to do a little summary. The ListView "list" is created on the Alloy's xml file, it has only one section, created dynamically by code. I attached a marker event to the list, where I launch my search function. My search function can append result or not, if I launch it from the marker I append, otherwise before I clear the list. At the end of my search function I set a marker, but only if the last result gave at least one result. I append the marker doing this: $.list.setMarker({ 'sectionIndex': 0, 'itemIndex': $.list.sections[0].items.length - 1 - parseInt(pageSize * 0.7) }); On the event itemclick of the list, if the pressed bindId is of my delete button, I delete the row using: $.list.sections[0].deleteItemsAt(itemIndex,1); Without deleting everything works well, but if I press the "delete button" on the list the marker event isn't lanuched.
  4. Papia Chowdhury 2015-04-10

    Hello We have tested this issue. According to documentation: “The marker event is fired only once. You need to use the setMarkermethod again to set a new item threshold and the marker event will be fired once again.” Marker event works as expected. Its not a bug. Testing Environment: Titanium Sdk: 3.5.0 GA, 3.5.1GA Titanium CLI: 3.4.1 iOS simulator: iphone 4s(v8.1) OS X version: 10.9.5 Steps to Test: 1.Run below code 2.Tap on any row and delete 3.Scroll down(Row appends as expected) Possible Workaround:
       var win = Ti.UI.createWindow({backgroundColor: 'white', fullscreen: true});
       var listView = Ti.UI.createListView();
       var section = Ti.UI.createListSection();
       var sectionData = [];
       var i = 25;
       for (var k = 0; k < 25; k++) {
           sectionData.push({
               properties : {
                   title: 'Row ' + (k + 1)
               }
           });
       }
       section.setItems(sectionData);
       listView.sections = [section];
       win.add(listView);
       win.open();
       
       // Set the initial item threshold
       listView.setMarker({sectionIndex:0, itemIndex: (i - 1) });
        
       // Load more data and set a new threshold when item threshold is reached
       listView.addEventListener('marker', function(e){
           var max = i + 25;
           var data = [];
           for (var k = i; k < max; k++) {
               data.push({
                   properties : {
                       title: 'Row ' + (k + 1)
                   }
               });		
           }
           section.appendItems(data);
           i = i + 25;
           listView.setMarker({sectionIndex:0, itemIndex: (i - 1)});
       });
       
       
        //listview event listener
        listView.addEventListener('itemclick', function(e){ 
       
           var section = e.section;
       
           var itenIndex = e.itemIndex;
       
           var confirm = Ti.UI.createAlertDialog({
       
               title : 'Delete the row?',
       
               buttonNames : ['Yes','No']
       
           });
       
           confirm.addEventListener('click', function(e){
       
               if(e.index == 0){
       
                   section.deleteItemsAt(itenIndex,1);
                   //again set the thresh hold
        listView.setMarker({sectionIndex:0, itemIndex: (itenIndex+1) });
                   }
               });		
       
           confirm.show();
       });
       

JSON Source