i'm trying to generate a table dynamically from information from the database, no problem until i get to rowspan i am having difficulty comming up with a solution to implement rowspan successfully.
here is what i have so far
db:
ID | Row | Column | ColumnSpan | RowSpanloop through each record from the database
1 | 0 | 0 | 0 | 0
2 | 0 | 1 | 0 | 0
3 | 0 | 2 | 0 | 0
4 | 0 | 3 | 0 | 0
5 | 1 | 1 | 2 | 0
6 | 1 | 2 | 0 | 2
7 | 2 | 0 | 0 | 0
8 | 2 | 1 | 0 | 0
9 | 2 | 2 | 0 | 0
10 | 2 | 3 | 0 | 0
should generate something like
,-------------------,
| | | | |
`````````````````````
| | |
```````````````` `
| | | | |
`-------------------`
{
check if currentRecord.Row < table.Rows && currentRecord.Column < table.Rows[currentRecord.Row].Cells
{
// do column span
int spanTo = currentRecord.ColumnSpan;
while (spanTo > 1)
{
t.Rows[currentRecord.Row].Cells.RemoveAt(currentRow.Column + 1) // keep removing the column next to the current
spanTo -= 1;
} // this works nicely, problem is the below rowspan code
spanTo = currentRecord.RowSpan;
while (spanTo > 1)
{
t.Rows[currentRecord.Row + 1].Cells.RemoveAt(currentRecord.Column); // so from the example above, ID=5 is spanned, ID6 gets column=2, when it tries to rowspan it looks up column=2 from the row below, which is not correct
spanTo -= 1;
}
}
}
at the moment it ends up like this:
,-------------------,
| | | | |
`````````````````````
| | |
```````````````` `
| | |ERRO| |
`-------------------`
maybe im going about this the wrong way, any ideas on how i can implement something like this?
thanks
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.