2013-12-03 2 views
1

Надеюсь получить текст списка в виде списка, я не могу найти способ его получить. мой ListView код сборки:TITANIUM как получить значение listview?

var myTemplate = { 
    childTemplates: [ 
      {       // Title 
      type: 'Ti.UI.Label',  // Use a label for the title 
      bindId: 'info',   // Maps to a custom info property of the item data 
      properties: {   // Sets the label properties 
       color: 'black', 
       font: { fontFamily:'Arial', fontSize: '20dp', fontWeight:'bold' }, 
       left: 0, top: 0, 
      } 
     }, 
     {       // Subtitle 
      type: 'Ti.UI.Label',  // Use a label for the subtitle 
      bindId: 'es_info',  // Maps to a custom es_info property of the item data 
      properties: {   // Sets the label properties 
       color: 'black', 
       font: { fontFamily:'Arial', fontSize: '20dp' }, 
       right: 0, top: '0dp', 
       accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE 
      } 
     } 
    ] 
}; 

var table = Ti.UI.createListView({ 
// Maps myTemplate dictionary to 'template' string 
    templates: { 'template': myTemplate }, 
    bottom:'50dp', 
    editing : true, 
    defaultItemTemplate: 'template' 
}); 
var sections = []; 


ProcuctRS = db.execute('select uniqnumber,barcode,scantimes,quantity from product where batchno=?',Titanium.App.Properties.getString("batchnumber")); 
while (ProcuctRS.isValidRow()) 
    { 
     var BNO = ProcuctRS.fieldByName('barcode'); 
     var SCTIME = ProcuctRS.fieldByName('scantimes'); 
     var QUANTITY = ProcuctRS.fieldByName('quantity'); 

     var PDSection = Ti.UI.createListSection({ headerTitle: BNO}); 
     var PDDataSet = [ 
          { es_info: {text: 'Scan times :' + SCTIME}, info: {text: 'Quantity :'+ QUANTITY}}, 
         ]; 
     PDSection.setItems(PDDataSet); 
     sections.push(PDSection); 
     ProcuctRS.next(); 
    } 
ProcuctRS.close(); 
table.sections = sections; 
self.add(table); 

теперь я хочу изменить эту информацию и es_info текст, я пробовал различные метамфетамин, , например:

table.addEventListener('itemclick', function(e){ 
      var item = e.section.getItemAt(e.itemIndex); 
      e.section.es_info.color = 'orange'; 
      e.section.updateItemAt(e.itemIndex, item); 
}; 

, но он не работает. что я могу сделать? Help! спасибо

ответ

3

Я не знаю, если это уместно (или просто скопировать-вставить ошибка), но вы пропустили «)» в конце вашего слушателя событий

table.addEventListener('itemclick', function(e){ 
     var item = e.section.getItemAt(e.itemIndex); 
     e.section.es_info.color = 'orange'; 
     e.section.updateItemAt(e.itemIndex, item); 
}); 
+2

no I found Я должен использовать item.es_info.color – user3050782

0

редактирования попробовать: ложному

var table = Ti.UI.createListView({ 
     // Maps myTemplate dictionary to 'template' string 
     templates: { 'template': myTemplate }, 
     bottom:'50dp', 
     editing : false, 
     defaultItemTemplate: 'template' 
    }); 
Смежные вопросы