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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:53:35+00:00 2026-06-11T09:53:35+00:00

I am trying to sort the each columns in my JQGrid but its not

  • 0

I am trying to sort the each columns in my JQGrid but its not working. Please refer my code below and help me

//View Code

     $("#JQGridID").jqGrid({
                            url: '/Control/ActionResult/',
                            datatype: 'json',
                            mtype: 'POST',
                            colNames: ['Number', 'Unit'],
                            colModel: [
              { name: 'NNumber', index: 'Number', align: 'left', sortable: true, sorttype: 'int' },
              { name: 'NUnit', index: 'Unit', align: 'Center', sortable: true }
              ],                            pager: jQuery('#pager'),
                            cmTemplate: { title: false },
                            width: widthValue - 15,
                            height: 435,
                            rowNum: 20,
                            rowList: [20, 30, 40, 50, 60],
                            viewrecords: true,
                            gridComplete: loadCompleteFunction,
                            altRows: true,
                            sortorder: 'desc',
                            sortname: 'Number',
                            sortable: true,
                            onSortCol: function (index, idxcol, sortorder) {
                    if (this.p.lastsort >= 0 && this.p.lastsort !== idxcol
                            && this.p.colModel[this.p.lastsort].sortable !== false) {
                        $(this.grid.headers[this.p.lastsort].el).find(">div.ui-jqgrid-sortable>span.s-ico").show();
                    }
                }
,
                            onSelectRow: showMessageDetails,
                            postData: {
                        },

                        loadError: function (xml) { alert('Unable to load result data.'); }
                    });

//Control code

 [HttpPost]
        public ActionResult GetSearchPositionResult(string sidx, string sord, int page, int rows)
        {
            _Object = new PositionModel();
            _Object.CurrentPage = page;
            _Object.PageRowCount = rows;
            _Object.load();
            var result = new
            {
                total = _Object.TotalPages,
                page = page,
                sort = sidx,
                sord = sord,
                records = _Object.TotalRows,
                            rows = _ObjectPM.SearchResult.Select(p => new
            {
                cell = new string[]{
                 p.Number,
                 p.Unit
                },sidx
            }).OrderBy(a => a.sidx).ToArray(),                };
            return Json(result, JsonRequestBehavior.AllowGet);
        }
  • 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-11T09:53:37+00:00Added an answer on June 11, 2026 at 9:53 am

    In case of datatype: 'json' the sorting of data (sortable: true in colModel) is not handled on client-side by jqGrid but it has to be handled on server-side by your code. In another words you need to sort your _Object.SearchResult by the column name which you will receive in sidx parameter (the sorting direction is passed in sord parameter).

    Here you can find a sample project which can help with using jqGrid in ASP.NET MVC: jqGrid in ASP.NET MVC 3 and Razor

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to sort a view model binding on multiple properties. The problem is
So i'm trying to understand all the code from the NotePad sample, but i'm
I am trying to use all columns for each row from one table (party),
Trying to sort this array of objects according to (1) depth and (2) weight,
Been trying to sort this one out for a while. I'd really appreciate any
I am trying to sort a list of names followed by another string such
I am trying to sort an array in PHP by date and time which
I'm trying to sort by the state of an Organization's main address. I have
I am trying to sort a two-dimensional array by a timestamp column Descending. This
I am trying to sort pixel values of an image (example 80x20) from lowest

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.