{ "id": "98731", "key": "TIMOB-10328", "fields": { "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "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": "14065", "description": "Sprint 2012-17 API", "name": "Sprint 2012-17 API", "archived": true, "released": true, "releaseDate": "2012-08-27" }, { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-08-27T13:06:34.000+0000", "created": "2012-08-06T11:31:41.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "api", "parity", "qe-port" ], "versions": [ { "id": "13505", "description": "Release 3.0.0", "name": "Release 3.0.0", "archived": true, "released": true, "releaseDate": "2012-12-14" } ], "issuelinks": [ { "id": "19698", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "outwardIssue": { "id": "98726", "key": "TIMOB-10324", "fields": { "summary": "TiAPI: Add support for accessing and manipulating TableViewSections from a TableView", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } }, { "id": "19730", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "97839", "key": "TIMOB-10106", "fields": { "summary": "APIDoc: Document \"header\" property in TableViewRow", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "5", "description": "The sub-task of the issue", "name": "Sub-task", "subtask": true } } } } ], "assignee": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-01-14T02:26:14.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Accessing table view sections from a table view is currently limited to the data property which resets the entire table. This makes it extremely expensive to, say, add a new section to an already existing table. It has also given rise to poorly thought out API designs such as the 'header' property of TableViewRows.\r\n\r\nWe need to add methods for accessing and manipulating TableViewSections in a TableView akin to how we can access TableViewRows from a TableView.\r\n\r\nWe also need to document and deprecate the previously undocumented 'header' property.", "attachment": [], "flagged": false, "summary": "Android: Add support for accessing and manipulating TableViewSections from a TableView", "creator": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "213949", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Hello. :)\r\n\r\n\r\n(I'm a bit late, but ...) In my experience, manipulating TableViewSections is not extremely expensive operation. I using technique described in this Gist: https://gist.github.com/2775243 (the trick is in resetting TableView's \"data\" property). Works very fast.\r\nBut - it's not elegant at all. I actually suggested that instead of using \"setData\" property, \"add\" method could be used. That way, sections could be added at any time. The only issue here is missing \"insertAt\" method.\r\n\r\n\r\nSo ... IMHO, true solution would be implementation of similar API for all UI components (TIMOB-7671) that would enable developers to do anything - at any time. I'm not fan of component specific names like \"insertSectionBefore\". That kind of naming convention is confusing and hard to remember (where \"add\" goes, where \"addRow\", is it \"addSection\" or just \"add\", etc.).\r\n\r\n\r\nP.S. I don't like my TableView API that I suggested in TIMOB-7671. In library that I wrote (that is - in Titanium object wrappers) I am using two types of TableView (SimpleTableView and TableView) and two types of TableViewRow (SimpleTableViewRow and TableViewRow). SimpleTableView is TableView that has no sections (not even default) and TableView is TableView with TableViewSections. On the other hand SimpleTableViewRow is TableViewRow that does not contain other components (it can have \"title\" property, but does not have \"add\" method), while TableViewRow is TableViewRow that can contain other components.\r\nThat way, API is more cleaner and less confusing (row's index is particularly painful topic when everything is mixed together).", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-08-11T13:05:43.000+0000", "updated": "2012-08-11T13:05:43.000+0000" }, { "id": "214009", "author": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Your method isn't fast if you have a large TableView (hundreds if not thousands of rows).\r\n\r\nWhat to do with the add() method is tricky...there is a lot of historical baggage surrounding it and we need to take into account all of the existing apps, plus sometimes add doesn't actually make sense given underlying components. It's something we've been thinking about though, because, as you said, it is confusing.\r\n", "updateAuthor": { "name": "bhughes", "key": "bhughes", "displayName": "Bryan Hughes", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-13T09:03:57.000+0000", "updated": "2012-08-13T09:03:57.000+0000" }, { "id": "214287", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Hm, could be, didn't test on large tables ... I thought that, in theory, it shouldn't be slow (because all sections and rows are already created).\r\n\r\n\r\n\r\nOK, I understand. Thanks for the answer.", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2012-08-14T06:32:56.000+0000", "updated": "2012-08-14T06:32:56.000+0000" }, { "id": "215366", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "For functional test:\r\n1. Run the test case below.\r\n2. Click \"append sections\" to see the table view sections.\r\n3. Click other buttons to manipulate table view sections.\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor: \"white\",\r\n\tlayout: \"vertical\"\r\n});\r\n\r\nvar index = 0;\r\nvar view = Ti.UI.createView({\r\n\tbackgroundColor: \"white\",\r\n\theight: 100\r\n});\r\nvar label = Ti.UI.createLabel({\r\n\ttext: \"section index: i=\" + index,\r\n\tcolor: \"black\",\r\n\tfont: {fontSize: 24, fontWeight: \"bold\"},\r\n\tleft: 50\r\n});\r\nvar b1 = Ti.UI.createButton({\r\n\ttitle: \"i++\",\r\n\tleft: 300\r\n});\r\nb1.addEventListener(\"click\", function() {\r\n\tindex ++;\r\n\tlabel.text = \"section index: i=\" + index\r\n});\r\nvar b2 = Ti.UI.createButton({\r\n\ttitle: \"i--\",\r\n\tleft: 400\r\n});\r\nb2.addEventListener(\"click\", function() {\r\n\tindex --;\r\n\tlabel.text = \"section index: i=\" + index\r\n});\r\nview.add(label);\r\nview.add(b1);\r\nview.add(b2);\r\n\r\nvar appendButton = Ti.UI.createButton({\r\n\ttitle: \"append sections\"\r\n});\r\n\r\nvar count = 0;\r\nappendButton.addEventListener(\"click\", function() {\r\n\tcount++;\r\n\t\r\n\tvar section = Ti.UI.createTableViewSection({\r\n\t\theaderTitle: \"Appended Section \" + count,\r\n\t\tfooterTitle: \"Footer \" + count\r\n\t});\r\n\ttable.appendSection(section);\r\n \r\n var sections = [{headerTitle: \"Appended Sections \" + count, footerTitle: \"Footer \" + count},\r\n \t\t\t\t{headerTitle: \"Appended Sections \" + count, footerTitle: \"Footer \" + count}];\r\n\ttable.appendSection(sections);\r\n\talert(\"sectionCount = \" + table.sectionCount);\r\n});\r\n\r\nvar deleteButton = Ti.UI.createButton({\r\n\ttitle: \"delete section at index i\"\r\n});\r\n\r\ndeleteButton.addEventListener(\"click\", function() {\r\n\ttable.deleteSection(index);\r\n\talert(\"sectionCount = \" + table.sectionCount);\r\n});\r\n\r\nvar updateButton = Ti.UI.createButton({\r\n\ttitle: \"update section at index i\"\r\n});\r\n\r\nupdateButton.addEventListener(\"click\", function() {\r\n\tvar section = Ti.UI.createTableViewSection({\r\n\t\theaderTitle: \"Updated Section \" + index,\r\n\t\tfooterTitle: \"Footer \" + index\r\n\t});\r\n\tsection.add(Ti.UI.createTableViewRow({ title: 'Updated Section - Row' }));\r\n\ttable.updateSection(index, section);\r\n});\r\n\r\nvar insertBeforeButton = Ti.UI.createButton({\r\n\ttitle: \"insert section before index i\"\r\n});\r\n\r\ninsertBeforeButton.addEventListener(\"click\", function() {\r\n\tvar section = Ti.UI.createTableViewSection({\r\n\t\theaderTitle: \"Insert Section Before \" + index,\r\n\t\tfooterTitle: \"Footer \" + index\r\n\t});\r\n\tsection.add(Ti.UI.createTableViewRow({ title: 'Insert Section Before - Row' }));\r\n\ttable.insertSectionBefore(index, section);\r\n\talert(\"sectionCount = \" + table.sectionCount);\r\n});\r\n\r\nvar insertAfterButton = Ti.UI.createButton({\r\n\ttitle: \"insert section after index i\"\r\n});\r\n\r\ninsertAfterButton.addEventListener(\"click\", function() {\r\n\tvar section = Ti.UI.createTableViewSection({\r\n\t\theaderTitle: \"Insert Section After \" + index,\r\n\t\tfooterTitle: \"Footer \" + index\r\n\t});\r\n\tsection.add(Ti.UI.createTableViewRow({ title: 'Insert Section After - Row' }));\r\n\ttable.insertSectionAfter(index, section);\r\n\talert(\"sectionCount = \" + table.sectionCount);\r\n});\r\n\r\nvar table = Ti.UI.createTableView({});\r\n\r\nwin.add(view);\r\nwin.add(appendButton);\r\nwin.add(deleteButton);\r\nwin.add(updateButton);\r\nwin.add(insertAfterButton);\r\nwin.add(insertBeforeButton);\r\nwin.add(table);\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-21T11:55:56.000+0000", "updated": "2012-08-27T10:44:10.000+0000" }, { "id": "215367", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR https://github.com/appcelerator/titanium_mobile/pull/2792", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-21T11:56:28.000+0000", "updated": "2012-08-21T11:56:28.000+0000" }, { "id": "234137", "author": { "name": "amittal", "key": "amittal", "displayName": "Anshu Mittal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested with:\r\nSDK: 3.0.0GA\r\nStudio: 3.0.1.201212181159\r\n\r\nWorks as expected", "updateAuthor": { "name": "amittal", "key": "amittal", "displayName": "Anshu Mittal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-01-14T02:26:14.000+0000", "updated": "2013-01-14T02:26:14.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }