0

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.)

  1. How can I compute the total sum of all the selected rows ?

  2. 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)

Misi
  • 748
  • 5
  • 21
  • 46

1 Answers1

0

You can do this by dom manipulation using jquery or even with plain js. find the rows where checkbox is checked, find relevant number fields and add them. you will get the result. Jquery selectors are ideal to perform this task.

Muhammad Adeel Zahid
  • 17,474
  • 14
  • 90
  • 155