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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:16:08+00:00 2026-05-25T17:16:08+00:00

I am using jqgrid treeview with an asp.net-mvc backend and i see the GUI

  • 0

I am using jqgrid treeview with an asp.net-mvc backend and i see the GUI lets you click on other columns for sorting but i can’t find any documentation or examples on how to implement it.

When I click a column heading, my “Loading . . ” notification shows up but none of my server side actions are getting called.

I used httpwatch and i don’t see any calls trying to hit the server.

Does jqgrid treeview support sorting (this would just be sorting the top level in the tree)?

Here is my code:

$("#treegrid").jqGrid({
    url: '/MyController/GetData' + GetQuery(),
    datatype: 'json',
    footerrow: true,
    userDataOnFooter: true,
    mtype: 'GET',
    rowNum: 2000,
    colNames: ["ID", "Description", "Total 1"],
    colModel: [{
        name: 'id',
        index: 'id',
        width: 1,
        hidden: true,
        key: true
    }, {
        name: 'desc',
        width: 240,
        index: 'desc',
        hidden: false,
        sortable: true
    },
            {
                name: 'total1',
                sorttype: 'int',
                index: 'total1',
                unformat: originalValueUnFormatter,
                formatter: bookMapFormatter,
                align: "right",
                width: 60,
                hidden: false,
                sortable: true
            }],
    treeGridModel: 'adjacency',
    height: 'auto',
    loadComplete: function (data) {


    },
    pager: "#ptreegrid",
    treeGrid: true,
    ExpandColumn: 'desc',
    ExpandColClick: true,
    caption: "My Treegrid"
});


 function bookMapFormatter(cellvalue, options, rowObject) {
     return booksFormatterEx(cellvalue, options, rowObject, "MyAction");
 }

function booksFormatterEx(cellvalue, options, rowObject, actionName) {
    var regularURL = '/MyController/' + actionName + GetQuery() + '&key=' + rowObject[0];
    return "<a target='_blank' href='" + regularURL + "' >" + cellvalue + "</a>";

}

Also if its helpful, i have serialized my json results (using the .net JavascriptSerializer class) (this is just the top level view as i go back to the server when users drill down)

 {"page":1,
 "total":1,
 "records":2,
 "userdata":{"desc":"Total:","total1":"10,753"},
 "rows":[{
 "id":"Group1","cell":["Group1","1 - 1 System(s)",723, 0, null, false, false, true]},
 {"id":"Group2","cell":["Group2","2 - 2 System(s)",2120, 0, null, false, false, true]},
 {"id":"Group3","cell":["Group3","3 - 3 System(s)",2017, 0, null, false, false, true]},
 {"id":"Group4","cell":["Group4","4 - 4 System(s)",1181, 0, null, false, false, true]},
 {"id":"Group5","cell":["Group5","5 - 5 System(s)",4712, 0, null, false, false, true]}]}
  • 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-25T17:16:09+00:00Added an answer on May 25, 2026 at 5:16 pm

    Tree grid has SortTree method which will be used to sort grid locally. No call to the server will be done. If the user click on the column header the same method will be called.

    For better understanding I take your attention on one line from the jqGrid code:

    if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";}
    

    which will be executed in case of usage datatype: 'json' or datatype: 'json'. So after the first loading of Treegrid the datatype will be changed to datatype: 'local'.

    Depend on the other jqGrid data (loaded:true or loaded:false) the expanding of the tree node will be locally or the request will be send to the server. In any way the sorting of the data will be always implemented locally.

    The only thing which if important to have correct sorting: one should use parent: "null" or parent: null in the data (not parent: "") for the root nodes (see here for details).

    UPDATED: Additionally to the problem with parent: "null" or parent: null (which you not have in the JSON data) you have the problem with the usage of HTML inside of JSON response from the server. The JSON data which you posted are equivalent to the following:

    {
        "page": 1,
        "total": 1,
        "records": 2,
        "userdata": {
            "desc": "Total:",
            "bookmapBooks": "10,753"
        },
        "rows": [
            {"id": "Group1", "cell": ["Group1", "<b>COMMODITIES</b> - 19  System(s)",         "<b>723</b>"]},
            {"id": "Group2", "cell": ["Group2", "<b>CREDIT</b> - 30 System(s)",               "<b>2,120</b>"]},
            {"id": "Group3", "cell": ["Group3", "<b>EQUITIES</b> - 23 System(s)",             "<b>2,017</b>"]},
            {"id": "Group4", "cell": ["Group4", "<b>MORTGAGE PRODUCTS</b> - 33 System(s)",    "<b>1,181</b>"]},
            {"id": "Group5", "cell": ["Group5", "<b>RATES AND CURRENCIES</b> - 40 System(s)", "<b>4,712</b>"]}
        ]
    }
    

    As I described before, the datatype of the grid will be changed to the 'local' after the first data load. The internal data parameter will be filled with the JSON data exactly in the format like you has in the JSON input. So for the column 'total1' you would has data like "<b>723</b>" or "<b>4,712</b>" which corresponds not the sorttype: 'int'. So adding "0", "null" for level: 0, parent: null will not full solve the problem of the grid sorting. The string "<b>4,712</b>" can’t been converted to int and so can’t be sorted as integer.

    One more small remark. You probably want to use "userdata":{"desc":"Total:","total1":"10,753"} instead of "userdata":{"desc":"Total:","bookmapBooks":"10,753"}.

    With respect of the usage of sorttype as function you could solve your problem and change the original grid

    to the sortable grid

    You can use the sorttype in the following form:

    sorttype: function (val) {
        var strValue = $(val).text().replace(",",""); // replace thousandsSeparator
        return parseInt(strValue, 10);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jqGrid in an ASP.NET MVC webapp. When the page first loads, the
So I'm using jqGrid with my mvc.net / Ling2Sql prototype site that I'm making
i m using jqGrid along with asp.net mvc2... the problem is that i m
I'm using jqGrid in an asp.net page. It is bound to an SqlDataSource object
I am using jqGrid control in an ASP.NET application. Export to Excel feature is
I am using JQGrid in my solution in which i load tabs dynamically, but
Hi I'm using jqgrid to show some information in a grid. But I have
i am using jqgrid treeview and i am passing back json response which works
I am using jqGrid , but it cannot take attributes from a xml file.
I'm using jqGrid with mvc 2 like this: jQuery(#extension_grid).jqGrid({ url: '/Extension/Report', datatype: json, direction:

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.