I have a ASP.NET MVC 4 application with EF. In my Index view I have a webgrid with a list of items. At the bottom of the page I have calculated the sum of my webgrid items(Total value). I have a checkbox at the end of every row.
@helper SumFunc()
{
decimal sum = ((IEnumerable<itemstable>)Model).Sum(i => i.value);
@sum
}
@grid.GetHtml(columns: grid.Columns(
grid.Column(columnName: "name", header: "Name", format: @<text>@item.name</text>, canSort: true),
grid.Column(columnName: "value", header: "Value", format: @<text>@item.value</text>, canSort: true),
grid.Column(" ", " ", //@Html.CheckBox() or <input type="checkbox" />
grid.Column(" ", " ", format: @<a href="@Url.Action("SomeMethod", "Home", new { id = item.id_comanda })">Proiectare</a>)))
<p> Total value : @SumFunc(something) Selected value sum: @SumSelFunc(somethingelse) </p>
I want to calculate the sum for all the checked rows at the bottom of the page (I have a checkbox at the end of every row.)
How can I compute the total sum of all the selected rows ?
How can I Edit all the selected rows ? Let's say the checkbox says Shipped and if I select some items I want to modify only one field (bool Shipped = true)