{ "id": "60858", "key": "TIMOB-226", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11216", "name": "Release 0.8.0", "archived": true, "released": true, "releaseDate": "2009-11-20" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:52:25.000+0000", "created": "2011-04-15T02:25:43.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "feature", "ios", "iphone" ], "versions": [], "issuelinks": [], "assignee": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:52:25.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

Description

\n

Support custom layouts for native table views using\ntemplates

\n
\n\n//\n// create template\n// three types are supported: image, text, button\n//\nvar template = {\n selectedBackgroundColor:'blue', \n selectedBackgroundImage:'foo.png', \n selectedColor:'white', \n height:'auto'  // this allows for rows to auto expand\n layout:[\n   {type:'image', left:0, top:0, width:30, height:40},\n   {type:'text', fontSize:20, fontWeight:'bold', left:30, top:10, width:100},\n   {type:'text', fontSize:13, left:30, top:30, width:150, height:'auto', color:'#336699'},\n   {type:'button', text:'Delete', backgroundColor:'red', color:'white'}\n\n]};\n\n//\n//  table data\n//\nvar data = [\n  {\n    selectedRowColor:'red',\n    height:20,\n    data:[{image:'foo.png'}, {title:'My Title'}, {title:'My detail text'}, {title:'delete'}]\n  },\n  {\n    selectedBackgroundImage:'bar.png',\n    data:[{image:'foo.png'}, {title:'My Title2', fontSize:30}, {title:'My detail text2'}, {title:'delete'}]\n  }\n\n];\n//\n// create table view (\n//\nvar tableView = Titanium.UI.createTableView({template:template, data:data, function(e)\n{\n   // e.layout (template object that was clicked)\n   // e should contain all other normal table view row click data\n\n});\n
{html}", "attachment": [], "flagged": false, "summary": "Custom Table View", "creator": { "name": "nwright", "key": "nwright", "displayName": "Nolan Wright", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "nwright", "key": "nwright", "displayName": "Nolan Wright", "active": false, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "122963", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I'm really uncertain about the usage of 'auto', because it could\nbe very expensive. It would require, on first\ndisplaying the table view, effectively rendering all cells, visible\nor not, in order to determine the row heights.

\n

Furthermore, this happens before the tableView is given an\nactual size, I'm not sure I'll have correct widths beforehand.

\n

Additionally, the array of dictionaries is a lot of\ndereferencing and feels inelegant. I'd want template and the actual\ndata cell to be identical in structure.

\n

since rowHeight is used in table and picker columns, it should\nbe consistent and be used in template and data.

\n

I also am not sure about the button type, because it presents\nsome complexities as it's reinventing widgets that are already\navailable.

\n
\nvar template = {\n backgroundColor:'white',\n selectedBackgroundColor:'blue', \n selectedBackgroundImage:'foo.png', \n selectedColor:'white',\n rowHeight:40,\n layout:[\n   {type:'image', left:0, top:0, width:30, height:40, name:'image'},\n   {type:'text', fontSize:20, fontWeight:'bold', left:30, top:10, width:100, name:'title'},\n   {type:'text', fontSize:13, left:30, top:30, width:150, height:'auto', color:'#336699', name:'detailText'},\n]};\n\n//\n//  table data\n//\nvar data = [{\n    selectedBackgroundColor:'red',\n    rowHeight:20,\n    image:'foo.png',\n    title:'My Title',\n    detailText:'My detail text'\n  },{\n    selectedBackgroundImage:'bar.png',\n    image:'foo.png',\n    title:'My Title2',\n    detailText:'My detail text2'\n    layout:[\n       {type:'image', left:0, top:0, width:30, height:40, name:'image'},\n       {type:'text', fontSize:30, fontWeight:'bold', left:30, top:10, width:100, name:'title'},\n       {type:'text', fontSize:13, left:30, top:30, width:150, height:'auto', color:'#336699', name:'detailText'},\n  ]}\n];\n//\n// create table view (\n//\nvar tableView = Titanium.UI.createTableView({template:template, data:data, function(e){\n   e.index //Total row index, counting all rows in all sections above it.\n   e.section //section index, the number of sections that precede the section of this row.\n   e.row //Row index, the number of rows in this section that precede this row.\n   e.detail //Boolean, indicates that, if hasDetail was true, and the user pressed it\n   e.rowData // The actual contents of the data representing the row that was pressed.\n   e.layoutName //The 'name' of the field touched.\n});\n
\n

In this, data becomes a free-form object, where non-keyword\nvalues are used by layout to fill in the appropriate property. It\nalso allows individual cells (Or possibly sections) to completely\noverride the template layout.

{html}", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:25:44.000+0000", "updated": "2011-04-15T02:25:44.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }