This is a migrated thread and some comments may be shown as answers.

How to get members of a Json object

1 Answer 132 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Anton Swanevelder
Top achievements
Rank 2
Anton Swanevelder asked on 13 Dec 2012, 10:30 AM
Hi,

Pretty sure this is my lack of Json knowledge but how can I get a member in a Json object returned?

I am also using a DataSource here is there any other suggested way to get data that will not be bound to a control?

test: function () {
        var dataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "http://search.twitter.com/search.json?q=anton",
                    dataType: "jsonp"
                }
            },
            requestStart: function (e) {
                $('#loadingMain').show();
            },
            requestEnd: function (e) {
                alert(dataSource.data().completed_in);
            },
            error: function (e) {
                alert(e.status);
            }
        });
 
        dataSource.read();
    }
If you guys can add more simple non-bound examples to your documentation please.

Thanks,
Anton

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 15 Dec 2012, 08:52 AM
Hello Anton,

The result returned from the server is available through the response event argument in the requestEnd event as described in the documentation. From the code snippet it seems that you are trying to access a custom field returned from the server:

requestEnd: function (e) {
    alert(e.response.completed_in);
},
The dataSource data method returns an observable array.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Anton Swanevelder
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Share this question
or