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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:55:40+00:00 2026-06-14T20:55:40+00:00

I have to display some data that I receive from the server as json

  • 0

I have to display some data that I receive from the server as json object like this

{"rowndx":"0","rows":"25","rowstotal":"100","rowsdata":[ 
["00","DEVICE001","T0_IHOME","1","***","1","10"], 
["01","DEVICE002","NO_DEVICE","1","***","1","10"],
["02","DEVICE003","NO_DEVICE","0","***","1","10"],
.....

Before displaying the received data in a table I would like to make changes where necessary adding units to the numbers or replacing the numbers with words (eg 0 ->OFF 1-> ON)
To do this I have associated at the ajax option “success” my encoding function. In this case, however, remains always visible the message “Loading …” and no other action is permitted.
I moved my re-encoding procedure to the “complete” ajax option and this time it seems to work.
But I did not understand what was my mistake and I do not know if my procedure can work.
This is my table ajax configuration

    url      : "devtbl.json",
    mtype    : "POST",
    datatype : "json",
    postData : ......

    ajaxGridOptions: {
      type       : 'post',
      contentType: 'application/json',
      async      : false,
      complete   : DEVparse_serverdata,
      error      : function() { alert('Something bad happened. Stopping');},
    },

    jsonReader : {
      root        : "tablerows",
      page        : "currentpage",
      total       : "totalpages",
      records     : "totalrecords",
      cell        : "",
      id          : "0",
      userdata    : "userdata",
      repeatitems : true
    },

and my coding function

    function DEVparse_serverdata(js , textStatus) {

  var jsontablereply = {} ;
  var rowsxpage_int  = parseInt(UB.rowsxpage.DEVtable) ;
  var jsonreply =  jQuery.parseJSON(js.responseText) ;

  jsontablereply.currentpage  = "" + (1 + (parseInt(jsonreply.rowndx) / rowsxpage_int));
  jsontablereply.totalpages   = "" + parseInt((parseInt(jsonreply.rowstotal) + (rowsxpage_int-1)) / rowsxpage_int) ;
  jsontablereply.totalrecords = jsonreply.rowstotal;

  jsontablereply.tablerows = [] ;
  $.each(jsonreply.rowsdata, function(ndx, row) {
     var rowarray = [] ;

     rowarray[0] = row[0] ;
     rowarray[1] = row[1] ;
     rowarray[2] = row[2] ;
     rowarray[3] = row[3] ;
     rowarray[4] = row[4] ;

     switch (row[2]) {
       case "NO_DEVICE":
            rowarray[5] = "***" ;
            break ;

       case "T0_IHOME":
            rowarray[5] = "T=" + row[5] + "°C" ;
            break ;
     }
     jsontablereply.tablerows[ndx] = rowarray ;
  }) ; // each

  jQuery("#DEVtbl")[0].addJSONData(jsontablereply);
}

(I am a beginner with Jquery my coding style is poor)

  • 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-14T20:55:41+00:00Added an answer on June 14, 2026 at 8:55 pm

    There are many possibilities which you have to implement your requirements.

    In many case one can use predefined formatter: “select” or formatter: “checkbox” for the case 0 ->OFF 1-> ON.

    Another possibility is the usage of custom formatter and unformatter. The custom formatter is just callback which will be used by jqGrid during building of HTML fragment of cells of the corresponding column. If you need common displaying of some text the formatter will look like

    formatter: function (cellValue) { return $.jgrid.htmlEncode(cellValue); }
    

    The advantage of custom formatter is that you can not only many any modification of the source text, but you can build the cell contain based of information from other columns (see rawData parameter below)

    formatter: function (cellValue, options, rawData, action) {
        // options is the the object defined as
        //         {rowId:rowId, colModel:cm, gid:gridId, pos:colpos }
        // rawData contains the representation of the WHOLE row
        //         the most problem of the value is that it is in the same
        //         format as the input data. So if will be array of items
        //         in your case or if could be XML fragment for the row.
        //         Additional problem one will have in case of usage of
        //         loadonce:true. Ath the first load the rawData will be
        //         array of strings and on later could be named object
        //         with the properties corresponds to the column names.
        // action is typically non-important and is 'add' or 'edit'
    }
    

    For example the custom formatter of the 5-th column can be

    formatter: function (cellValue, options, rawData, action) {
        switch (rawData[2]) {
        case "NO_DEVICE":
            return "***";
        case "T0_IHOME":
            return "T=" + $.jgrid.htmlEncode(cellValue) + "°C" ;
        default:
            return $.jgrid.htmlEncode(cellValue);
        }
    }
    

    One more option is the usage of beforeProcessing callback. It is mostly close tothe logic of your current code. Inside of beforeProcessing callback you can make any modifications of the data returend fron the server before the data will be processed by jqGrid.

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

Sidebar

Related Questions

I have some data being loaded from a server, but there's no guarantee that
I have a page that display some data. It is loaded from a database
I have some data that I have to display as a table. I think
I have some data that I want to display as a box plot using
I have a JTable that I want to use to display some data (a
I have been trying to display some basic EXIF data from a photo with
I have an activity which displays some data fetched from the server. If no
I have an webapp that is expected to fetch and display data from an
I have a UITableView that displays some data that is read in at runtime
Here is the scenario: I have a visual that displays some data The data

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.