jsgrid load data from web service

1.6k Views Asked by At

I'm new to jsgrid, and I'd like to know what I'm doing wrong.

I can load the grid with data just fine if I populate a JavaScript array within the page. However, I'm failing to load the grid data from a remote web service.

Here's my JavaScript code when the page loads on the client (similar to the one found at here):

$("#table1").jsGrid({
    width: "100%",
    inserting: true,
    editing: true,
    sorting: true,
    paging: true,
    filtering: true,
    autoload: true,
    pageSize: 12,
    pageButtonCount: 5,
    noDataContent: "No data was found",
    deleteConfirm: function(item) {
        return "Do you really want to delete the IPv4 address " + item.IPv4Address + "?";
    },
    controller: {
        loadData: function() {
            var d = $.Deferred();
            $.ajax({
                type: "POST",
                url: "proxy_ws.php",
                data: "action=getdata",
                dataType: "json"
            }).done(function(result) {
                console.log("get data (done): ", result);
                console.log("get data value (done): ", result.value);
                // d.resolve(result.value);
                d.resolve(result);
            });
            return d.promise();
        }
    },
    fields: [{
        name: "IPv4Address",
        title: "IPv4 Address",
        type: "text",
        width: 120,
        validate: "required"
    }, {
        name: "Timeout",
        title: "Timeout",
        type: "number",
        width: 50
    }, {
        name: "Description",
        title: "Description",
        type: "text",
        width: 200
    }, {
        name: "Signature",
        title: "Signature",
        type: "text",
        width: 50,
        editing: false
    }, {
        type: "control"
    }]
});

The console in Firefox shows these messages:

get data (done): Object { IPv4Address: "10.215.144.48", Timeout: 300, Description: "This is a test.", Signature: "no sig..." } test:380:11 get data value (done): undefined

Obviously, the web service at "proxy_ws.php" outputs:

{"IPv4Address":"10.215.144.48","Timeout":300,"Description":"This is a test.","Signature":"no sig..."}

However, nothing is being loaded in the grid. Is the format incorrect?

Incidentally, I haven't found a working demo on the net.

Thanks

0

There are 0 best solutions below