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

remote datasource never calls home

1 Answer 88 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 01 May 2012, 09:02 PM
Hi,

I had been using Sinatra pumping JSON to jqGgrid so I know my App works great. I decided to try out this Kendo UI as it reminds me of ExtJS which I have used extensively.

I setup a simple datasource pointing to my route supplying JSON

var ds = new kendo.data.DataSource({
    transport: {
      read: {
        url: "/admin/users",
        dataType: "json"
      }
    }
  });
 
And then a super simple grid:

$("#user-grid").kendoGrid({
      dataSource: {
        data: ds,
        pageSize: 10
      },
      height: 360,
      columns: [ {
              field: "firstname",
              width: 90,
              title: "First Name"
          } , {
              field: "lastname",
              width: 90,
              title: "Last Name"
          } , {
              field: "email",
              title: "Email",
              width: 200
          }
      ]
    });

This setup never calls the route for the data? The data source is thus empty, and hence the grid throws an error. 

I see nothing wrong, but then again, I have only used this KendoUI for 10 minutes. What am I missing here. Seems loading a datasource remotely like that should just work, but my route for the data is not even hit... 

If I change my grid to use dataSource: {data: ds:read()} then the ajax fires off and a nice string of JSON comes along, but nothing gets rendered in the grid. 

Kinda demoralizing when the basic do not work. Anyone have a hint or tip???

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 03 May 2012, 12:10 PM
Hi Dave,

The variable ds is a dataSource, not a simple JavaScript array and you cannot pass it to the data property.
The correct syntax is:
var ds = new kendo.data.DataSource({
    transport: {
      read: {
        url: "/admin/users",
        dataType: "json"
      }
    },
    pageSize: 10
});
 
$("#user-grid").kendoGrid({
    dataSource: ds
    height: 360,
    //...
});

I hope this helps.

Greetings,
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!
Tags
Data Source
Asked by
Dave
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or