Hello. My model is filled from the json line, where for each element any label, type, value, etc. are passed. There are also row properties (row) and column (column). And on the view, in the table for each element I create the necessary tag (depends on type), everything is ok.

Only they go all in order from top to bottom, that is, each tag is wrapped in

<tr><td>...<tr/><td/> 

Is it possible to somehow make it so that several td (in a loop) fall into one tr? For example, if I have 3 elements in one line

 { row=0, column=0 }, { row=0, column=1 }, { row=0, column=2 } 

it should work

 <tr><td>...<tr/><td>...<tr/><td>...<tr/><td/>. 

Or is it really possible to do this without a table?

  • It should be like this: <tr> <td> 1 </ td> <td> 2 </ td> <td> 3 </ td> </ tr> - Konst
  • @Konst Well, that's what I wrote. The point is that all tr ​​and td are created in my cycle - Ivan Maslov
  • one
    it means you first need to build an array of all row from json, and only then process it line by line in a cycle - Konst

1 answer 1

Maybe I don’t understand something, but I agree with Konst, you have the wrong sequence of tags. It seems that you insert tags in one cycle, but to build a table you need to use 2 cycles, the second will be nested, something like:

 @for(int r = 0; r < rowCount; r++) { <tr> for(int c = 0; c < columnCount; c++) { <td>...</td> } </tr> } 
  • Just noticed that I have a typo there. Yes, that's what I did, on a tip from Konst - Ivan Maslov