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

Remote Data Source

3 Answers 131 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 01 Sep 2011, 03:07 PM
I know this should be easy, but I'm having a hell of a time trying to get my remote data source working with templates. Can you give a quick example of how to bind a json datasource to a template (not inline)? Thanks!

I've tried all of the demos online, but none seem to work as I'd expect.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 02 Sep 2011, 08:09 AM
Hi Scott,

 The binding to remote data demo shows how to read data from remote service (twitter) and display that data using templates.

All the best,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Scott
Top achievements
Rank 1
answered on 02 Sep 2011, 03:26 PM
Thanks for the help! I was missing the call to: 
this.view()
0
d2uX
Top achievements
Rank 1
answered on 28 Aug 2012, 10:09 AM
Hi there,

I have a similar issue: I just dont know what I'm doing wrong...
Since it works with local data I think to format of the returned data is wrong.
Here is my datasource (js file):
var home = new kendo.data.DataSource({
    transport:
    {
        parameterMap: function(_options, _op)
        {
            if (_op == 'read')
            {
                return {
                    ObjectPath: '/Shops/DemoShop/',
                    ViewAction: 'JSONRestGet',
                    Attributes: 'Slogan'
                };
            }
        },
        read:
        {
            url: 'DemoShop.admin/',
            type: 'GET',
            dataType: 'jsonp',
            cache: true
        }
    },
    change: function(e) {
        var template = kendo.template($("#headerTpl").html());
        $('#header').html(kendo.render(template, this.view()));
        console.log(this.view());
    }
});

And here is how the server response looks like:
window["jQuery1710052283771103248_1346149420815"]({
   "Alias" : "DemoShop",
   "Slogan" : {
      "en" : "English Slogan",
      "de" : "Deutscher Slogan"
   },
   "Self" : "MyDemoShop"
}
);

Can anyone spot what I am missing?
Do I have to reformat that response?
The template just never gets rendered.

Thx in advance.
Tags
Templates
Asked by
Scott
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Scott
Top achievements
Rank 1
d2uX
Top achievements
Rank 1
Share this question
or