3

I have a ListView that's hooked to a dataCollection, is it possible to add editActions?

Can't seem to find a way to add these to my ItemTemplate or ListItem.

Here's my (shortened) view:

<ListView id="listViewSpots" defaultItemTemplate="history">
    <Templates>
        <ItemTemplate name="history" id="itemTemplateHistory" canEdit="true">
            <Label bindId="serie" class="serie" />
        </ItemTemplate>
    </Templates>
    <ListSection id="listSectionSpots" dataCollection="spot" dataFilter="listFilter">
        <ListItem itemId="{id}" serie:text="{serie}" searchableText="{serie}" />
    </ListSection>
</ListView>
Fokke Zandbergen
  • 3,866
  • 1
  • 11
  • 28
Rick
  • 75
  • 4

3 Answers3

2

You can add custom actions like this:

"ListItem[platform=ios]":{
accessoryType: Titanium.UI.LIST_ACCESSORY_TYPE_DISCLOSURE,
editActions: [{ title: "Add",
                style: Ti.UI.iOS.ROW_ACTION_STYLE_DEFAULT },
                { title: "Archive",
                style: Ti.UI.iOS.ROW_ACTION_STYLE_DEFAULT },]
}
Pooya
  • 6,083
  • 3
  • 23
  • 43
Michael Bahl
  • 2,941
  • 1
  • 13
  • 16
  • Doh, this is the most straightforward answer. Had to put it on the ItemTemplate though. You can even put actions on a specific template this way. Thank you! – Rick Apr 20 '16 at 12:22
0

Editable and EditActions are just regular properties of a ListItem and can be added as such. Through a transform function (dataTransform) you can make this customizable as well

<ListView id="listViewSpots" defaultItemTemplate="history">
    <Templates>
        <ItemTemplate name="history" id="itemTemplateHistory" canEdit="true">
            <Label bindId="serie" class="serie" />
        </ItemTemplate>
    </Templates>
    <ListSection id="listSectionSpots" dataCollection="spot" dataFilter="listFilter">
        <ListItem 
          itemId="{id}" 
          serie:text="{serie}" 
          searchableText="{serie}" 
          editable="{editable}"
          editActions="{editActions}"
       />
    </ListSection>
</ListView>

This way you can still configure it per ListItem

Rene Pot
  • 24,681
  • 7
  • 68
  • 92
-2

Yes it is possible.

Can you specify your issue ?

Can you enable slide action? Do you wanna know how to handle click event?

Maybe this can help you: "ItemTemplate[platform=ios]":{ canEdit: true }

  • I added some code, i want to add custom editActions to the listitems instead of the default "Delete". – Rick Apr 20 '16 at 10:55