1

Trying to get jqGrid to work with Google fusion tables.

Can't seem to find the event in jqGrid that allows you to control where it gets data from.

Would accept an equivalent javascript table engine that does this job better.

If you could link to an example or provide one in your answer, thanks.


Edit: OK here is how far I've gotten

I know how to get jqGrid to request the Google fusion tables but I can't get it to parse the JSON. I can't seem to find any decent documentation for the jsonreader part of jqGrid that explains what each variable does.

http://cablegate.politicswiki.ie/test.html is where I'm currently at.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • see the answer here: http://stackoverflow.com/questions/4317646/jqgrid-returns-blank-cells/4326986#4326986 – Oleg Dec 01 '10 at 21:38

3 Answers3

1

Seems to be quite a bit of flexibility:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options

Worse case scenario you can convert Google Fusion to XML or JSON in a script and render it that way.

methodin
  • 6,717
  • 1
  • 25
  • 27
  • The first link makes sense, but is unhelpful as I explained to user158913 however the second one I'm not sure how it's relevant. Either way neither of them are helpful, so if you look at the edit I've made to the original question you can see where I've gotten to and perhaps be able to assist me from there? –  Nov 30 '10 at 16:03
  • There is good documentation on it: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs Took me a while to find that – methodin Dec 06 '10 at 16:21
1

It is not event but property. See example here: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data You can define data source as JSON, function, xml, etc.

Vadym Chekan
  • 4,977
  • 2
  • 31
  • 24
  • Yes I had a look at that, fairly sparse documentation really with no examples of dealing with alternate json formats –  Nov 30 '10 at 16:01
0

This should work:

jsonReader: {
    repeatitems: false,
    root: function (obj) { 
        var rows = new Array();
        for(var rowNum = 0; rowNum < obj.table.rows.length; rowNum++)
        {
            var row = new Object();
            for (var colNum = 0; colNum < obj.table.cols.length; colNum++) {
                row[obj.table.cols[colNum]] = obj.table.rows[rowNum][colNum];
            }
            rows.push(row);
        }
        return rows;
    },
    page: function (obj) { return 1; },
    total: function (obj) { return 1; },
    records: function (obj) { return obj.table.rows.length; }
}

And don't forget to change the name property of the ident column to id as that is the name that Google Fusion Tables sends it with, you can leave the label as ident if you like.

BAH
  • 136
  • 5
  • I like to use functions in `jsonReader`, but simple settings `cell: "", root: "table.rows"` inside of `jsonReader` will already solve the problem (see my answer on the same question under http://stackoverflow.com/questions/4317646/jqgrid-returns-blank-cells/4326986#4326986) – Oleg Dec 03 '10 at 17:15