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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:34:54+00:00 2026-06-18T07:34:54+00:00

My jqGrid contains a special column whose value is generated by another value, like

  • 0

My jqGrid contains a special column whose value is generated by another value, like the Duration Span column, its real value is in seconds like 3690s, and I should transform it to a formmatted string ‘Hour : Minute : Second’, in this cause it is ‘1:1:30’. Now, I want to it works well in sortting, so I write a customize function to handle this:

1, Following code fragment is column definition:

{
    name : 'time',
    index : 'time',
    align: 'center',
    width :  '12%',
    sorttype : sortTimeFuc
} 

2, Following code fragment is sort function:

var sortTimeFuc = (function(cell) {
    var a = cell.split(':');
    var value = parseInt(a[2]) + parseInt(a[1]) * 60 + parseInt(a[0]) * 3600;
    return value;
});

But it work incorrectly as below:

enter image description here

Can anybody gives me help? Thanks so much.

  • 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-18T07:34:55+00:00Added an answer on June 18, 2026 at 7:34 am

    It seems to me that you make some errors. First of all you should remove parentheses over the function. Unneeded parentheses can follow to invocation of the function. The second and the most important error which I see in your code is the usage of parseInt without the second parameter 10. The last error is the usage of width : '12%'. jqGrid don’t support ‘%’ inside of width. Instead of that you can use just width: 12 and specify width of the total grid or use autowidth: true. Because the option shrinkToFit: true is default option if will follow to scaling the width of the columns based on the total width of jqGrid and width property of the column, which will define the proportion between the columns.

    So the resulting code could be as the following

    {
        name: 'time',
        align: 'center',
        width: 12,
        sorttype: function (cell) {
            var a = cell.split(':');
            return parseInt(a[2], 10) + parseInt(a[1], 10) * 60 +
                parseInt(a[0], 10) * 3600;
        }
    }
    

    See the answer as an example of very close implementation of custom sorting.

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

Sidebar

Related Questions

If column text contains characters like \<a only first character, \ is displayed in
My jqgrid contains several pages. When I sort any column the page resets to
jqGrid contains quantity column and add to cart button using colmodel below. Inline editing
I have a jqgrid that contains some data, the first column of which is
I am using jqgrid. My page has three tabs and each tab contains a
In my asp.net MVC 3 application am using Jqgrid as my grid. It contains
I have a table (jqGrid) and I'd like to add a small icon/image before
I have a jqGrid which contains folders and documents. I want to be able
I have a JQgrid which contains has just 2 columns..I am pasting my code
jqGrid add forms contains autocomplete boxes using code below. If new row is added

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.