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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:38:24+00:00 2026-06-01T19:38:24+00:00

I’m having trouble using the jQgrid, when I initialize the jqgrid with json datatype

  • 0

I’m having trouble using the jQgrid, when I initialize the jqgrid with json datatype it results to an error:

obj is undefined

ret = obj[expr];

When I initialize the jqgrid with local datatype, the error will not occur but the json data will not be loaded

index.html

<table id="products"></table>
<div id="pager"></div>

<script type="text/javascript">
$('document').ready(function(){
    jQuery("#products").jqGrid({
        url: 'product.php',
        editurl: 'product_update.php',
        datatype: "json",
        mtype: 'POST',
        colNames:['Product Name'],
        colModel:[
            {name:'product_name',index:'product_name', width:90}
        ],
        rowNum:-1,
        viewrecords: true, 
        rowList:[10,20,30],
        pager: '#pager',
        toolbar : [true,"top"],
        sortorder: "DESC",
        caption:"Products",
        width: 940,
        height: "100%"
    });
});
</script>

product.php (this is a mock data only)

    $arrayName = array();
    $arrayName['page'] = 1;
    $arrayName['total'] = 1;
    $arrayName['records'] = 3;
    $arrayName['rows'][0] = array(
        'product_name' => 'Product X'
        );
    $arrayName['rows'][1] = array(
        'product_name' => 'Product Y'
        );
    $arrayName['rows'][2] = array(
        'product_name' => 'Product Z'
        );

    echo json_encode($arrayName);

json output:

{"page":1,"total":1,"records":3,"rows":[{"product_name":"Product X"},{"product_name":"Product Y"},{"product_name":"Product Z"}]}

I’m hoping someone can help me here.

Thank you in advance 😀

  • 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-01T19:38:26+00:00Added an answer on June 1, 2026 at 7:38 pm

    Default input format of JSON data – array of items with ids like

    {"page":1,"total":1,"records":3,"rows":[
        {"id":"Product X", "cell":["Product X"]},
        {"id":"Product Y", "cell":["Product Y"]},
        {"id":"Product Z", "cell":["Product Z"]}
    ]}
    

    (see here). To read the data which you currently posted you should add jsonReader: {repeatitems: false, id: "product_name"} option to jqGrid definition.

    The most compact input you would have if you would use jsonReader: {cell: "", id: "0"}. In the case you should change the format of the JSON data to

    {"page":1,"total":1,"records":3,"rows":[
        ["Product X","Product Y","Product Z"]}
    ]}
    

    Additionally I would not recommend you to use rowNum:-1. The usage of some positive value which is large enough is better. For example rowNum: 10000. If you would add loadonce: true to the grid having rowNum:-1 you will that jqGrid will render grid in wrong way.

    You should add gridview: true to improve it performance. The last remark: is the usage of index:'invdate' was typing error?

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to

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.