Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6912885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:08:52+00:00 2026-05-27T09:08:52+00:00

I have two partial views on my main index page with a filter dropdown.

  • 0

I have two partial views on my main index page with a filter dropdown. One partial view is for displaying a list of emps and the other is a roll-up for totaling emp.salary, etc. Currently, I can update my main emp grid via ajax when the filter dropdown is selected. The issue is that, my roll-up grid needs to be re-calculated each time a new filter is applied to the main emp grid and I’m not sure how to go about that.

Less details view models here is the code:

Controller: Person/Index()

// GET: /Person/
public ViewResult Index()
{
   IList<Person> ppl = cs = db.Persons.ToList();

   PersonRollup pr= new PersonRollup();            
   foreach (Person p in ppl)
   {
      pr.salary += ii.salary
   }
   PersonViewModel pvm = new PersonViewModel{Persons = ppl, PersonsRollup = pr}
   return View(pvm);
}

View: Person/Index

@model Models.PersonVM>

@Html.ListBox("Filter")  

<div id="PersonRollupGrid">@Html.Partial("_PersonsRollup", Model.PersonsRollup)</div>

<div id="PersonGrid">@Html.Partial("_Persons", Model.Persons)</div>  

@* Filter selected from drop down *@
<script type="text/javascript">
    $("select").multiselect({
        click: function () {
            $.get('@Url.Action("FilterPersons")', function (data) {
                $('#PersonGrid').html(data);
            });
            // ???????????????????????????????????????????
            //   How can I update the rollup grid here....
            //???????????????????????????????????????????
            }
        });
</script>

Shared View: _Persons

@model IEnumerable<Models.Person>

<table>
    <tr>
        <th>Name</th>
        <th>Salary</th>
    </tr>

    @foreach (var item in Model) {
    <tr>
        <td>@item.name</td>
        <td>@item.salary</td>
    </tr>
</table>

Shared View: _PersonsRollup

@model Models.PersonRollup

<table>
    <tr>
        <th>TotalSalary</th>
    </tr>
    <tr>
        <td>@model.salary</td>
    </tr>
</table>

Controller: Filter

  public ActionResult FilterPersons(string someFilteredData)
  {
    IList<Person> ppl = cs = db.Persons.Where(/*someFilteredData*/).ToList();

   PersonRollup pr= new PersonRollup();            
   foreach (Person p in ppl)
   {
      pr.salary += ii.salary
   }
   PersonViewModel pvm = new PersonViewModel{Persons = ppl, PersonsRollup = pr}

   return PartialView("_Persons", ppl.Persons);
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:08:52+00:00Added an answer on May 27, 2026 at 9:08 am
     //get the filtered viewmodel data
     $.get('@Url.Action("FilterPersons")', function (data) { 
          //pass viewmodel to get rendered view             
          $("#PersonGrid").load("/Person/GetPersonsView"
             data.Persons, function () {
               //callback
          });
          //pass viewmodel to get rendered view       
          $("#PersonRollupGrid").load("/Person/GetPersonsRollUpView",
             data.PersonsRollup, function () {
               //callback
          });
    
     });
    
    
      public ActionResult FilterPersons(string someFilteredData)
      {
           ....
           return JsonResult(pvm, JsonRequestBehavior.AllowGet);
      }
    
      public ActionResult GetPersonsView(Persons persons)
      {   
          return PartialView("_Persons", persons);
      }
    
      public ActionResult GetPersonsRollUpView(PersonRollup personRollup)
      {   
          return PartialView("_PersonsRollUp", personRollup);
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On some View page I have two partial views (their html is the same).
I have an asp.net view which has two partial views. One for edit information
I have one (razor) page that contain 5 different partial views. Each partial view
I have an MVC 3 page that has two partial views, one for Items
I'm using MVC2 with VS2010 I have a view that has two partial views
I have two different views that makes upwards of 500 partial view calls each
I have a layout which it has two partial views, one for LogIn and
I have two strongly-typed partial views (Developers list and Testers list) and the respective
I have two strongly Typed partial views (Developers list and Testers list) and the
I want to have two partial views , one for SEARCH and one for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.