[TIMOB-10328] Android: Add support for accessing and manipulating TableViewSections from a TableView
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-08-27T13:06:34.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Sprint 2012-17 API, Release 3.0.0 |
Components | Android |
Labels | api, parity, qe-port |
Reporter | Bryan Hughes |
Assignee | Ping Wang |
Created | 2012-08-06T11:31:41.000+0000 |
Updated | 2013-01-14T02:26:14.000+0000 |
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.
We need to add methods for accessing and manipulating TableViewSections in a TableView akin to how we can access TableViewRows from a TableView.
We also need to document and deprecate the previously undocumented 'header' property.
Hello. :) (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. But - 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. So ... 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.). P.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. That way, API is more cleaner and less confusing (row's index is particularly painful topic when everything is mixed together).
Your method isn't fast if you have a large TableView (hundreds if not thousands of rows). What 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.
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). OK, I understand. Thanks for the answer.
For functional test: 1. Run the test case below. 2. Click "append sections" to see the table view sections. 3. Click other buttons to manipulate table view sections.
PR https://github.com/appcelerator/titanium_mobile/pull/2792
Tested with: SDK: 3.0.0GA Studio: 3.0.1.201212181159 Works as expected