ListView dataSource error

2 posts, 1 answers
  1. Tyler
    Tyler avatar
    6 posts
    Member since:
    Jan 2012

    Posted 24 Mar 2012 Link to this post

    Hi everyone,
    I'm trying to put JSON object received by an AJAX Call, but i don't really know how to use it properly, when i try to convert it into an Object or trying to use it with no modification i don't get anything on the web page.

    Here is my JSON message : 
    [{"id":"3","views":"0","title":"Video1","description":"Video1.mp4","created_at":"2012-03-21 00:00:00","updated_at":"2012-03-21 00:00:00","link":"\/videos\/Video1.mp4","add_by":"1","category":"1","convert":"0","group_fkid":"1"},{"id":"2","views":"0","title":"Video2","description":"Video2.mp4","created_at":"2012-03-21 00:00:00","updated_at":"2012-03-21 00:00:00","link":"\/videos\/Video2.mp4","add_by":"1","category":"1","convert":"0","group_fkid":"1"},{"id":"1","views":"0","title":"Video3","description":"Video3.mp4","created_at":"2012-03-21 10:00:00","updated_at":"2012-03-21 10:00:00","link":"\/upload\/videos\/Video3.mp4","add_by":"1","category":"1","convert":"0","group_fkid":"1"},{"id":"4","views":"0","title":"Video de test","description":"31.mp4","created_at":"2012-03-21 00:00:00","updated_at":"2012-03-21 00:00:00","link":"\/upload\/videos\/31.mp4","add_by":"1","category":"1","convert":"0","group_fkid":"1"}]

    Can someone explain me the right way to use it with no error ?

  2. Answer
    Alexander Valchev
    Alexander Valchev avatar
    2887 posts

    Posted 26 Mar 2012 Link to this post

    Hi Tyler,

    I suggest to configure the dataSource component in order bind the ListView to remote data. Please check the corresponding documentation and review in details the transport and schema objects. Fist one is responsible for loading of the data via Ajax calls, while the second one is used to define the raw data format. For example:
    var dataSource = new{
        transport: {
            read: {
                url: <your url >,
                dataType: "json"
        schema: {
            model: {
                fields: {
                    id: { type: "number" },
                    title: { type: "string" },
                    description: { type: "string" },
                    updated_at: { type: "date" },
                    < describe rest of the fields >

    Once you have got the configured dataSource, you could pass it to the ListView widget as shown in the source code of this example.

    All the best,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top