Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Data not showing up, but receiving in correct format
22/08/2010
01:36
Avatar
drmoocow
Member
Members
Forum Posts: 3
Member Since:
22/08/2010
sp_UserOfflineSmall Offline

Hi, everyone. I know there's been threads like this in the past, but I've tried everything and I'm at my wit's end. I've been through past threads and the wiki looking for the answer but nothing seems to be working for me.

I'm using the 3.8 beta available on the homepage, everything seems to work ok, but no data gets inserted into the table upon retrieiving it via JSON.

Here's what I've got so far:

HTML

<table id="search_results" class="fm_hidden"></table>

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

JS

First, I declare colNames and colModel arrays because I need to add or remove a column based on which user is logged in. This is in a <script> section that's declared in the main php file:

var colNames = ['Inv#', 'Inv Date', 'Paid Date', 'Transco', 'Broker', 'TrCo Inv#', 'Load #', 'Amount', 'Curr', 'Days', 'Reserve'];
<?php if ( ! $restricted ) { ?>
    colNames.push('Profit');
<?php } ?>

var colModel = [
 { name: 'id', index: 'id', width: 35, sorttype: 'int', summaryType:'count', summartTpl: '({0}) total' },
 { name: 'date', index: 'date', width: 60, sorttype: 'date', formatter: 'date', datefmt: 'Y-m-d' },
 { name: 'datepaid', index: 'datepaid', width: 60, sorttype: 'date', formatter: 'date', datefmt: 'Y-m-d' },
 { name: 'transco_name', index: 'transco_name', width: 170 },
 { name: 'broker_name', index: 'broker_name', width: 170 },
 { name: 'tinvid', index: 'tinvid', width: 50 },
 { name: 'loadno', index: 'loadno', width: 70 },
 { name: 'amount', index: 'amount', width: 50, sorttype: 'number', formatter: 'number', summaryType: 'sum' },
 { name: 'currency', index: 'currency', width: 40 },
 { name: 'days', index: 'days', width: 40, sorttype: 'number', formatter: 'number' },
 { name: 'reserve', index: 'reserve', width: 50, sorttype: 'number', formatter: 'number', summaryType: 'sum'}
];
<?php if ( ! $restricted ) { ?>
    colModel.push( { name: 'profit', index: 'profit', width: 50, sorttype: 'number', formatter: 'number', summaryType: 'sum' } );
<?php } ?>

In the external javascript file, the function I use to call the grid and gather the search criteria builds the url and stores it in the "url" variable. In the interest of not making a mess, just assume that the url builds correctly (as it does).

jQuery("#search_results").jqGrid( {
    url: url,
    dataType: "json",
    colNames: colNames,
    colModel: colModel,
    rowNum: 1,
    rowList: [1,10,25,50],
    height: 'auto',
    pager: '#pager',
    viewrecords: true,
} );
jQuery("#search_results").jqGrid('navGrid','#pager',{edit:false,add:false,del:false});

JSON

The JSON result appears to have the correct layout. (formatted for clarity)

{
  "rows":[
    {
      "id":"50007",
      "cell": [
        "52407",
        "2007-06-27",
        "2007-08-17",
        "SAMPLE TRANSCO NAME",
        "SAMPLE BROKER NAME",
        "375",
        "1435",
        "$1435.00",
        "CAD",
        "51",
        1,
        2
      ]
    }
  ],
  "page":"1",
  "total":"1275",
  "records":"1275"
}

I also tried naming the fields and adding jsonReader: { repeatitems: false } to the jqGrid call, same result; I also tried putting the declaration of colNames and colModel into the jqGrid call and still got the same thing.

I know I'm missing something somewhere… but I can't figure out for the life of me where.

Help?

Cry

22/08/2010
07:05
Avatar
drmoocow
Member
Members
Forum Posts: 3
Member Since:
22/08/2010
sp_UserOfflineSmall Offline

Ok, so I solved my problem, but I don't really get why it was a problem.

In my jqGrid call, I had:

dataType: "json",

where, in fact, it is expecting:

datatype: "json",

Yell

Why is it that this variable is all in lower case, where other variables like colNames and colModel are in camelcase?

Hopefully me pulling my hair out (not that I had much to start with) will save someone else from pulling theirs out.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
29 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information