Reputation: 171
I have nested lists of objects passed through to the razor view from the controller.
If the nested list count is greater than 10, I need the first 10 objects to render in the first column and then the remaining to render in a second column.
I have tried everything within my power to make this happen! Any help with this would be greatly appreciated. I have had most success with .Skip() and .Take() methods.
Upvotes: 2
Views: 238
Reputation: 523
aha so what you want is
item01 item11 item21
item02 item12 item22
...
You need to loop thru for rows 0-9 and decide which item appears in which column. If this is correct, then make Items an array... hope this helps...
@for(row=0; row<10; ++row){
<tr>
@for(col=0; col<5;++col){
var idx = col * 10 + row;
if(idx>=Model.items.length){
<td> </td>
}else{
var itm = Model.items[col * 10 + row];
<td>itm</td>
}
}
</tr>
}
Upvotes: 2