0

I would like to create a backbone based page where there are undefined amount of columns and rows in a table-like layout. The 'table' structure and cell data should be saved to the backend.

The simplified models are:

row:

  • id
  • label

column:

  • id
  • label

cell:

  • rowID
  • columnId
  • value

in this situation a cell belongs to one row and one column.

If I add rows and columns dynamically how will the cells know what their rowID and columnId is especially in case of a newly added row+column which is not saved yet?

An other question is how I can connect a row of cells to a row object and at the same time a column of cells to a column object?

Thank you in advance, please let me know if you need more details.

materemias
  • 131
  • 1
  • 2
  • 7

1 Answers1

0

I would forget the concepts of rows and columns and just use index position for your cells.

If you have C columns and R rows, the cell at position Column = 2 and Row = 3 would be at position (3 - 1) * C + 2

This allows you to easily deal with changing numbers of columns and rows. You can also dynamically recalculate all objects that belong to a row or a column and then create object and row columns.

Running Turtle
  • 12,360
  • 20
  • 55
  • 73
  • this is a good idea, but I have to use the persistent data for other purposes too, in this way knowing which column or which row a given piece of information belongs to is essential. – materemias Sep 25 '12 at 11:16