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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:13:16+00:00 2026-06-15T14:13:16+00:00

I have a problem where I need to display json data on a jqgrid.

  • 0

I have a problem where I need to display json data on a jqgrid. The data I get is of the following format:

{"data":{"data":"\tat org.aaa.aaa.aaa.aaa.aaa.aaa(aaa.java:512)[147:org.aaa.aaa.aaa:9.1.1]\n\tat aaa.aaa.aaa.aaa.aaa.aaa(aaa.java:1789)[146:org.aaa:9.1.1]\n"}}

My javascript to display the data is:

 $("#grid").jqGrid({
  url: '/getdata',
      datatype: "json",
  mtype: "GET",
  colNames:['data'],
  colModel:[
     {name:'data', index:'data', align:'center'}
  ],
   jsonReader : {
          repeatitems: false,
      id: "0",
      cell: "",
       root: "logs",
      page: function() { return 1; },
      total: function() { return 1; },
      records: function(obj) { return obj.length; }
    },
   loadonce: true,      
   viewrecords: true,
   autowidth: true,
   multiselect: false,
   ignoreCase: true,
   sortable: true,
   height: 600, 
   rowNum: 999
 });

I tried a few combinations, but could not get the data to be displayed on the jqgrid with this code. The jqgrid displays an empty table. I guess I am missing something here.

I also have to format the data so that every time we hit ‘\n’, we display it in a new row. I guess I can use ‘addrowdata’ in the formatter for the column to do that. Is that right?

Any pointers are greatly appreciated.

thanks,

Asha

  • 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-15T14:13:18+00:00Added an answer on June 15, 2026 at 2:13 pm

    I don’t recommend you to use addRowData. It’s more effectively to use beforeProcessing to modify the data returned from the server to the format which jqGrid can read. You can for example to split the data.data part by \n and fill the array of the corresponding items:

    autoencode: true,
    beforeProcessing: function (data) {
        var items = data.data.data.split("\n"), i, l, item;
        data.logs = [];
        for (i = 0, l = items.length; i < l; i++) {
            item = $.trim(items[i]);
            if (item.length > 0) {
                data.logs.push([item]);
            }
        }
    }
    

    I included the call of jQuery.trim in the above code to remove unneeded \t or other white space characters at the beginning or at the end of every line.

    I included additionally autoencode: true option which is strict recommended to be sure that the texts which included special characters for HTML (like <, >, & and so on) will be correctly displayed inside of the grid.

    Additionally you should change jsonReader to for example the following

    jsonReader: {
        root: "logs",
        cell: "",
        id: function () {
            return function () {
                return $.jgrid.randId();
            }
        },
        page: function() { return 1; },
        total: function() { return 1; },
        records: function(obj) { return obj.logs.length; }
    }
    

    The value of id seems tricky, but the implementation generate really unique values for id attribute of every line.

    The corresponding demo you will find here.

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

Sidebar

Related Questions

I have the following problem: I need to use XSLFO to generate a 2-column
I have a problem with Matlab - I need to do the following :
I have a problem with Json formating returned from .ASMX I need to return
I have a problem with UIPopoverController. On button press I need to display the
I have a problem where I need a way to display a repeating series
So the problem is the following: I have an action method that returns json.
I need to display a google map with several markers. The problem I have
I have problem i need to convert from my Array structure to std::vector<int> ...
I have a problem where I need to split an input string into possible
I have a problem where I need to remove all code and triggers from

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.