c# - ASP.net MVC Table Grouping -
i need grouping data. have following bit below, data displayed based on foreach loop.
very straight forward stuff, need group item.party. there ever 2 , when click on 1 expands ( can use bootstrap bit that). grouping i'm bit confused , not sure start , best practise.
@foreach (var item in model.finplanexpenseview) { <tr> <td class="text-center"> @if (item.view_type == "budget") { @html.actionlink("x", "delete", item.view_type, new { id = item.finplan2_gid, returnaction = "incomeandexpenses" }, null) } else if (item.view_type == "livingexpenses") { @html.actionlink("x", "delete", item.view_type, new { id = item.finplan2_gid, party = item.party, returnaction = "incomeandexpenses" }, null) } else { @html.actionlink("x", "delete", item.view_type, new { id = item.source_gid, returnaction = "incomeandexpenses" }, null) } </td> <td> @if (item.view_type == "budget") { @item.desc } else if (item.view_type == "livingexpenses") { @item.desc } else { @item.desc } </td> <td class="numeric-column">r @html.displayfor(modelitem => item.amount)</td> <td class="text-right">@html.displayfor(modelitem => item.party)</td> <td class="text-right"> @if (item.view_type == "budget") { @html.actionlink("edit", "edit", item.view_type, new { id = item.finplan2_gid, returnaction = "incomeandexpenses" }, null) } else if (item.view_type == "livingexpenses") { @html.actionlink("edit", "edit", item.view_type, new { id = item.finplan2_gid, party = item.party, returnaction = "incomeandexpenses" }, null) } else { @html.actionlink("edit", "edit", item.view_type, new { id = item.source_gid, returnaction = "incomeandexpenses" }, null) } </td> </tr> }
any appreciated!
you can use orderby this. want party items after each other right?
change this: @foreach (var item in model.finplanexpenseview)
in
@foreach (var item in model.finplanexpenseview.orderby(f => f.party)
Comments
Post a Comment