Forum

November 2nd, 2014
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_Related Related Topics sp_TopicIcon
4.2.0 - JSON + repeatitems: false
14/10/2011
12:58
Avatar
Jenk
New Member
Members
Forum Posts: 2
Member Since:
14/10/2011
sp_UserOfflineSmall Offline

Hi Guys,

The following code renders an empty grid, am I doing something wrong?

Regards,

J.

The data:

{
   "TotalPages":1,
   "CurrentPageNumber":1,
   "NumberOfRecords":100,
   "Rows":[
      {
         "Id":1,
         "Cells":[
            {
               "RouteLegReference":"refA"
            },
            {
               "CarrierKey":"A"
            },
            {
               "CarrierName":"Carrier A"
            },
            {
               "CarrierReference":"a reference"
            }
         ]
      },
      {
         "Id":2,
         "Cells":[
            {
               "RouteLegReference":"refB"
            },
            {
               "CarrierKey":"B"
            },
            {
               "CarrierName":"Carrier B"
            },
            {
               "CarrierReference":"b reference"
            }
         ]
      },
      {
         "Id":3,
         "Cells":[
            {
               "RouteLegReference":"refC"
            },
            {
               "CarrierKey":"C"
            },
            {
               "CarrierName":"Carrier C"
            },
            {
               "CarrierReference":"c reference"
            }
         ]
      },
      {
         "Id":4,
         "Cells":[
            {
               "RouteLegReference":"refD"
            },
            {
               "CarrierKey":"D"
            },
            {
               "CarrierName":"Carrier D"
            },
            {
               "CarrierReference":"d reference"
            }
         ]
      },
      {
         "Id":5,
         "Cells":[
            {
               "RouteLegReference":"refE"
            },
            {
               "CarrierKey":"E"
            },
            {
               "CarrierName":"Carrier E"
            },
            {
               "CarrierReference":"e reference"
            }
         ]
      }
   ]
}

The code:

    $(function() {
        $("#routeLegGrid").jqGrid({
            url: '/data',
            datatype: 'json',
            mtype: 'GET',
            colModel: [
                    { name: 'RouteLegReference', label: 'Route Leg Reference', index: 'RouteLegReference', sortable: true, align: 'center' },
                    { name: 'CarrierKey', label: 'Carrier Key', index: 'CarrierKey', sortable: true, align: 'center' },
                    { name: 'CarrierName', label: 'Carrier Name', index: 'CarrierName', sortable: true, align: 'center' },
                    { name: 'CarrierReference', label: 'Carrier Reference', index: 'CarrierReference', sortable: true, align: 'center' },
                ],
            sortname: 'RouteLegReference',
            sortorder: 'asc',
            pager: $("#pager"),
            rowNum: 20,
            rowList: [20, 40, 60],
            caption: 'Route Legs, lol!',
            viewrecords: true,
            jsonReader: {
                root: "Rows",
                page: "CurrentPageNumber",
                total: "TotalPages",
                records: "NumberOfRecords",
                repeatitems: false,
                id: "Id"
            },
            width: 'auto',
            height: 'auto'
        });

        $("#reload").click(function() {
            $("#routeLegGrid").trigger("reloadGrid");
        });
    });

24/10/2011
19:21
Avatar
Jenk
New Member
Members
Forum Posts: 2
Member Since:
14/10/2011
sp_UserOfflineSmall Offline

Fixed it. It seems you can't use a "cell" value when using named values.

Here is an example of working JSON:

{
   "NumberOfPages":0,
   "CurrentPageNumber":1,
   "NumberOfRecords":3,
   "Rows":[
      {
         "Id":"35476669-28f1-4041-9390-cca731a208b1",
         "RouteLegReference":"35476669-28f1-4041-9390-cca731a208b1",
         "CarrierKey":"AA",
         "CarrierName":"AMERICAN AIRLINES",
         "CarrierReference":"123",
         "ManifestNotes":"notes",
         "Flight":"flight",
         "Origin":"St Lon-les-Mines",
         "Destination":"Hector International Apt"
      },
      {
         "Id":"b5bb1e68-6e58-47f8-9056-95043ca91471",
         "RouteLegReference":"b5bb1e68-6e58-47f8-9056-95043ca91471",
         "CarrierKey":"AA",
         "CarrierName":"AMERICAN AIRLINES",
         "CarrierReference":"reference",
         "ManifestNotes":"notes",
         "Flight":"FUCKING",
         "Origin":"Arenys de Mar",
         "Destination":"Paris"
      },
      {
         "Id":"c97e449f-29e7-419b-83cb-653b99d0d938",
         "RouteLegReference":"c97e449f-29e7-419b-83cb-653b99d0d938",
         "CarrierKey":"NYC1",
         "CarrierName":"NYC CARGO EXPORT",
         "CarrierReference":null,
         "ManifestNotes":null,
         "Flight":null,
         "Origin":"London",
         "Destination":null
      }
   ]
}
Forum Timezone: Europe/Sofia

Most Users Ever Online: 496

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