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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:32:09+00:00 2026-05-16T20:32:09+00:00

I need to change the default sort icons for the jqgrid . Currently it

  • 0

I need to change the default sort icons for the jqgrid. Currently it has an up and down arrow shown for each column. How can I replace it with a single icon that changes as it is clicked on?

Basically, the icon should toggle between ascending, descending and unsorted.


Solution

Using Oleg’s answer I changed the default double arrow icons to be a single red up or down arrow that toggles when sorted.

The jqGrid is wrapped in a div with a searchResults class.

This makes the header icons red:

.searchResults .ui-state-default .ui-grid-ico-sort.ui-icon
{
    background-image: url("../images/ui-icons_cd0a0a_256x240.png");
}

This centers the icons when only one icon is showing and the other is hidden:

.searchResults .ui-jqgrid .ui-icon-asc, .searchResults .ui-jqgrid .ui-icon-desc 
{
    height:12px;
    margin-top:0px;
}

This hides the inactive sort icon:

.searchResults .ui-state-disabled.ui-icon-desc, .searchResults .ui-state-disabled.ui-icon-asc
{
    display: none;
}
  • 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-16T20:32:10+00:00Added an answer on May 16, 2026 at 8:32 pm

    jqGrid use jQuery UI for the sort icons. You can implement your own theme intaractive on the http://jqueryui.com/themeroller/ and download it at the end of customization. If you only want to change the sort icons to other icons already existing in the theme you can do this more easy. But before all you have to understand how the icons will be used in the column headers.

    At the initialization time it will be created headers for all columns of jqGrid. Every header contain spans with the sort icons. The span blocks looks like following

    <span class="s-ico" style="display: none;">
         <span class="ui-grid-ico-sort ui-icon-asc ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-ltr" sort="asc" />
         <span class="ui-grid-ico-sort ui-icon-desc ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-ltr" sort="desc" />
    </span>
    

    Because of having “ui-icon” class the elements has background which come from the jQuery UI theme which you use. From the background will be used the parts corresponds to “ui-icon-triangle-1-n” and “ui-icon-triangle-1-s” icons. Classes ui-icon, ui-icon-triangle-1-n and ui-icon-triangle-1-s is defined as following

    .ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png)/*{iconsContent}*/; }
    .ui-icon-triangle-1-n { background-position: 0 -16px; }
    .ui-icon-triangle-1-s { background-position: -64px -16px; }
    

    If you want to replace there to other icons (see all standard available icons at the botom of http://jqueryui.com/themeroller/) you can do this for example directly after creating the jqGrid (after jQuery("#list").jqGrid({/*...*/});). If you don’t find in the background image the icons which you need you should better not change an existing icons. You can add some new parts in the background image which you use.

    There are no direct support for 3-state sort icons (ascending, descending and unsorted) in jqGrid. If you do want to implement this I’ll recommend you to read carefully implementation of sortData function of grig.base.js which you find in src subdirectory of downloaded jqGrid sources. This function call jQuery.hide() or jQuery.show() functions for the span.s-ico, add or remove ui-state-disabled class on one from the child spans and call onSortCol event handle if it is defined. So you can implement all changeing of sort icons inside of your custom onSortCol event handle.

    UPDATED: Free jqGrid fork have many options to customize sorting icons. First of all if supports Font Awesome icons. One need just include the Font Awesome CSS and the option . One can, for example, use threeStateSort: true to allow to display the item in original, unsorted order on th 3-d click on the column header. One can use sortIconsBeforeText: true to change the order of icons and the text. Placing of the sorting icons before the text could be helpful in case of usage long textes in the column headers. One can use showOneSortIcon: true option to show only one (desc or asc) sorting icons instead of two sorting icons (one over the second one or one near the second one).

    One can even full customize the sorting icons by overwriting $.jgrid.builderSortIcons method. The demo shows how one can use simple custom $.jgrid.builderSortIcons method to set *different sorting icons for differents columns. The demo uses three different icons depend on the type of data in the column. The columns with the default sorting type sorttype: "text" displays

    enter image description here and
    enter image description here

    the columns having numeric types (sorttype: "integer", sorttype: "int", sorttype: "float", sorttype: "number" or sorttype: "currency") displays

    enter image description here and enter image description here

    and all other column, for example, the column having sorttype: "date" displays

    enter image description here and enter image description here

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

Sidebar

Related Questions

I need to change the DataTemplate for items in a ListBox depending on whether
I need to change the functionality of an application based on the executable name.
I need to change the capitalization of a set of files in a subversion
I need to change a static property on an object in our web application.
I need to change an element's ID using jQuery. Apparently these don't work: jQuery(this).prev(li).attr(id)=newid
I need to change the app name based on what configuration I'm using in
I need to change the order of headers, I'm using this: HttpWebRequest request =
I need to change the connection speed of a port on a switch via
I need to change what rows are grabbed from the database based upon a
Possible Duplicate: Change CSS Dynamically I need to change the height of a div

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.