开发者

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

  1. win1 contains the table (table1) and an array that contains rows that you can update (data)
  2. 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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜