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

  • SEARCH
  • Home
  • 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 8548709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:33:27+00:00 2026-06-11T13:33:27+00:00

I have a ShoeItem class where I store a few Shoe attributes such as

  • 0

I have a ShoeItem class where I store a few Shoe attributes such as Model, Price, Color..

In the Index view of my ShoeController, I show the user a List of the shoes s/he requested using some filters, there is no problem here..

The list is shown in the default MVC 3.0 list view.. My @Model of the view page (“Index.cshtml”) is of type List<ShoeItem>

However, I want the user to be able to sort the resulting list according to those attributes both ascending or descending but I can not..

I tried calling a PartialViewResult from the ShoeController by sending back the List<ShoeItem> as parameter within Ajax.BeginForm, sort it back there and show a PartialView with this sorted list but the List parameter comes to the controller as null..

I also tried jQuery to do the sorting client-side but I could not reach the List<ShoeItem> object from jQuery.. I may post the code if you would like to see but it’s simple..

Any ideas?

  • 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-06-11T13:33:28+00:00Added an answer on June 11, 2026 at 1:33 pm

    There are 2 options

    1. Make an AJAX request to the server passing the sort parameters e.g. /shoes/?sort=model&dir=asc. Take these parameteres into the controller action, retrieve the items, sort them and return a JsonResult. Render the new list via JavaScript.
    2. Make an AJAX/full page request to the server with the sort params. Take these parameteres into the controller action, retrieve the items and return a PartialView for AJAX and a ViewResult for full page request.

    The first method is harder to maintain as you end up rendering from 2 different places – server and client. Although this would be made easier by using some kind of templating library like moustache: https://github.com/janl/mustache.js.

    For the second option you controller would look like the following. I’ve made some assumptions and it could probably be streamlined but helpfully it will get you started. If your shoes are stored in a database, make sure you do the filtering and ordering on an IQueryable – that way the database server will do it, rather than the data being returned to .NET, then filtering it.

    public ViewResult Index(int? colour, string sort, string dir)
    {
        IQueryable<Shoe> shoes = shoeService.GetAllShoes();
    
        // Filter by something
        if(colour.HasValue)
            shoes = shoes.Where(s => s.Colour = colour);
    
        // Order the items
        switch((sort ?? "").ToLower())
        {
            case "colour":
                if(dir == "desc")
                    shoes = shoes.OrderByDescending(s => s.Colour.Name);
                else
                    shoes = shoes.OrderBy(s => s.Colour.Name);
                break;
        }
    
        if(Request.IsAjaxRequest())
            return PartialView(shoes.ToList());
        return View(shoes.ToList());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one problem Looking below: I have this model: class Shoes(models.Model): shop =
have written this little class, which generates a UUID every time an object of
Have deployed numerous report parts which reference the same view however one of them
I have the following code in an MVC 3 view <% foreach (var stockItem
I have 3 file index.php, .js file, and a.php file. i made a ajax
Have the following scenario. I have a few form, which essentially have a few
Suppose I have an action: function actionShowItem($id) { $item = Item::model()->findByPk($id); $this->render(showitem,array('model' => $id));
have such kind of error. When adding Redirect 301 rule to .htaccess file like:
Have a text box which get data for price. If someone enter something like
Have such a problem, hope you'll help me.. Can't find anywhere. Here is the

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.