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 8460377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:35:24+00:00 2026-06-10T13:35:24+00:00

I’m trying to make a simplest possible table sorting for my MVC project, and

  • 0

I’m trying to make a simplest possible table sorting for my MVC project, and found this nice reference here jQuery table sort, although it doesn’t seem to work for me 🙁 There’s a JsFiddle test there as well which works of course ( http://jsfiddle.net/gFzCk ) but mine won’t.

This is the table I was trying to sort.

<table id="projectTable">
    <thead>
        <tr>
            <th id="name_header">
                Name
            </th>
            <th id="author_header">
                Author
            </th>
            <th>
                Date Created
            </th>
            <th>
                Date Edited
            </th>
            <th style="text-align:right;"> <a href="@Url.Action("Create", "Project")"><button>&nbsp;Create&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model) {
            var id = item.ProjectID;

            <tr id='@id' class="trow @if (System.Web.HttpContext.Current.Session["_SelectedProject"].ToString() == "System.Object") { <text>none</text> }
                            else
                            { if (id == (int)System.Web.HttpContext.Current.Session["_SelectedProjectID"]) {<text>highlighted</text> }}">
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Author)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DateCreated)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DateEdited)
                </td>
                <td>
                    <a href='@Url.Action("Edit", "Project", new { id = item.ProjectID })'><img src='@Url.Content("~/Content/images/Edit16x16.png")' title="Edit"/></a> &nbsp;
                    <a href='@Url.Action("Details", "Project", new { id = item.ProjectID })'><img src='@Url.Content("~/Content/images/Details16x16.png")' title="Details" /></a> &nbsp;
                    <a href='@Url.Action("Delete", "Project", new { id = item.ProjectID })'><img src='@Url.Content("~/Content/images/Delete16x16.png")' title="Delete" /></a> &nbsp;
                    <a href='@Url.Action("Select", "Project", new { id = item.ProjectID })' class="select"  ><img src='@Url.Content("~/Content/images/Select16x16.png")' title="Select"  /></a> 
                </td>
            </tr>
         }
    </tbody>
</table>

And this is JQuery I used.

<script type="text/javascript">
    var table = $('#projectTable');

    $('#name_header, #author_header')
        .wrapInner('<span title="sort this column"/>')
        .each(function () {

            var th = $(this),
            thIndex = th.index(),
            inverse = false;

            th.click(function () {

                table.find('td').filter(function () {

                    return $(this).index() === thIndex;

                }).sortElements(function (a, b) {

                    return $.text([a]) > $.text([b]) ?
                        inverse ? -1 : 1
                        : inverse ? 1 : -1;

                }, function () {

                    return this.parentNode;

                });

                inverse = !inverse;

            });

        });
</script>

I’ve already tested whether it runs the script or not, and it does, it just won’t sort it…

HTML Markup

I removed tbody and thead.

<table id="projectTable">
    <tr>
        <th id="name_header">
            Name
        </th>
        <th id="author_header">
            Author
        </th>

        <th>
            Date Created
        </th>
        <th>
            Date Edited
        </th>
        <th style="text-align:right;"> <a href="/Project/Create"><button>&nbsp;Create&nbsp;</button></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
    </tr>
    <tr id='1' class="trow  none ">
        <td>
            Project 1
        </td>
        <td>
            Me
        </td>

        <td>
            8/24/2012 7:08:49 PM
        </td>
        <td>
             8/24/2012 7:08:49 PM
        </td>
        <td>
            <a href='/Project/Edit/1'><img src='/Content/images/Edit16x16.png' title="Edit"/></a> &nbsp;
            <a href='/Project/Details/1'><img src='/Content/images/Details16x16.png' title="Details" /></a> &nbsp;
            <a href='/Project/Delete/1'><img src='/Content/images/Delete16x16.png' title="Delete" /></a> &nbsp;
            <a href='/Project/Select/1' class="select"  ><img src='/Content/images/Select16x16.png' title="Select"  /></a> 
        </td>
    </tr>
    <tr id='2' class="trow  none ">
        <td>
            Test Project 2
        </td>
        <td>
            Me
        </td>

        <td>
            8/27/2012 5:42:32 PM
        </td>
        <td>
            8/27/2012 5:42:32 PM
        </td>
        <td>
            <a href='/Project/Edit/2'><img src='/Content/images/Edit16x16.png' title="Edit"/></a> &nbsp;
            <a href='/Project/Details/2'><img src='/Content/images/Details16x16.png' title="Details" /></a> &nbsp;
            <a href='/Project/Delete/2'><img src='/Content/images/Delete16x16.png' title="Delete" /></a> &nbsp;
            <a href='/Project/Select/2' class="select"  ><img src='/Content/images/Select16x16.png' title="Select"  /></a> 
        </td>
    </tr>
</table>
  • 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-10T13:35:26+00:00Added an answer on June 10, 2026 at 1:35 pm

    In that case it sounds like you’re missing a reference to the sort library, try adding this before your main script tag with your jQuery usage:

    <script type="text/javascript" src="https://raw.github.com/padolsey/jQuery-Plugins/master/sortElements/jquery.sortElements.js"></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

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.