Append row to a section
There is a handy method to append new rows to a table but I do not see away to append rows to a section.The following code does not work as expected.
tableView.data[0].rowCount; // as an example reports 0
tableView.data[0].add(newRow);
tableView.data[0].rowCount; // would report 1 now
The row may have been added but it does not show up. Adding new rows with tableView.appendrow(newRow)
adds the row to the end of the table only.
Has anyone found a work around for this? I suppose I could use several tables in place of my single table but then I'd have to keep on top of my table height so that it all displays and doesn't appear to be viewable inside of a tiny window. If a tableView is put inside of a view or scroll would it then expand without me needing to resize or track the height of anything?
3 Answers
-
You could try
the_table.insertRowAfter( row_id , the_row_to_be_inserted )
where row_id is the Index of the last row in the section you want to insert. You will have calculate this row_id as a sum the rows found in the sections 0-X( X being the section you are inserting the row).
Hope it makes sense, and it's not tested :)
-
I just want to share that I have succesfully displayed the new rows inserted by adding two lines of code for 'refreshing' the tableview.
tableView.data[0].rowCount; // as an example reports 0 tableView.data[0].add(newRow); tableView.data[0].rowCount; // would report 1 now var temp = tableView.data; // save the data into a temporary variable tableView.setData(temp); // set the data back to refresh the tableview
Hope this helps…
-
I have the same problem! I am trying a workaround by having nested tables…will let you know how that goes..