Appcelerator. Update row labels
Titanium SDK version: 1.7.0 iPhone SDK version: 4.2
I am developing an iOS app using Appcelerator. In this app I got a window that contains a table of contact data. The user can click an item in this table and a new window opens up where they can edit the contact details and then click save.
After the user clicked save I want the table in the parent window to update its data for the clicked row with the info sent back from the edit window.
My question is. How can I update the labels in a specific row if I got the row index? I am planning to make this update开发者_运维问答 from a custom event so I will not be using e.index only the "saved" index number for example 5.
I know there is a function called "updateRow" but I seem to only be able to update title of the row not its child elements.
Thankful for all input!
Here is the approach I would take.
Assumptions
- win1 contains the table (table1) and an array that contains rows that you can update (data)
- win2 is where the editing occurs
On the 'save' button click in win2, fire an event with the updated contact details before you close the window;
Ti.App.fireEvent('contact.change' , updatedContactObject );
// Do database save here if required
win2.close();
Add an eventListener in win1:
Ti.App.addEventListener( 'contact.change' , function(e){
var updatedContactObject = e.updatedContactObject;
//
// update the array and the row here
//
data[ updatedContactObject.id ] = updatedRowData;
table1.setData(data);
});
In my experience it is best to tableView.setData(rowArray)
whenever you make a change, rather than selectRow, updateRow, etc. Regarding the actual row elements, you should be able to navigate by using row.children[x].children[x]. The problem is that you will have to pay close attention to the hierarchy. Let us know if you find a better way!
精彩评论