Forum Archive

Difference between section and row TableView

PetervdKamp

I'm trying to understand the difference between a section and a row in a TableView. When a create a datasource with e.g. 3 items and query the tableview_number_of_sections the answer is three. When I query the tableview_number_of_rows, then the answer is one, so one row in each section. My expectation however was: one section, 3 rows. So, can someone explain the difference between section and row and how they can be used within a TableView?

Thanks,

Peter

dgelessus

Sections are groups of rows, so for example in a file list you could have the sections "folders", "documents", "images", "sound", "videos". If you want a list without section headers, make tableview_number_of_sections return 1.

I'm not sure what you mean by "when I create a datasource" - are you using ui.ListDataSource or are you writing your own data source class? As far as I know ListDataSource doesn't support sections. If you're creating a custom data source, make sure that you inherit from object and that you implement all methods listed in the documentation.

PetervdKamp

OK, thanks, this makes things more clear to me. Yes, I've created a custom data source with the necessary methods, however tableview_number_of_sections does not return 1 and that's what I need.