最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Passing url to read as a parameter in kendoui datasource - Stack Overflow

programmeradmin0浏览0评论

Let's say I have this kind of simple dataSource:

var TasksSource = new kendo.data.DataSource({

     transport: {
         read: {
          url: 'some url',
          dataType: "json"
        }
    }
});

And I want to use it several times, but with different urls. I couldn't find anywhere how to pass this to dataSource. And I don't want to use global variable. I was trying with custom methods, like for example setUrl: function() .. etc but eventually it didn't work

Let's say I have this kind of simple dataSource:

var TasksSource = new kendo.data.DataSource({

     transport: {
         read: {
          url: 'some url',
          dataType: "json"
        }
    }
});

And I want to use it several times, but with different urls. I couldn't find anywhere how to pass this to dataSource. And I don't want to use global variable. I was trying with custom methods, like for example setUrl: function() .. etc but eventually it didn't work

Share Improve this question asked Jan 10, 2014 at 21:50 mmmmmmmm 3,9389 gold badges38 silver badges64 bronze badges 5
  • why wouldn't a function work? did you receive any errors? – Goose Commented Jan 10, 2014 at 22:05
  • when I was trying to use "TaskSource.setUrl('test')" it showed "Object [object Object] has no method 'setUrl' " – mmmm Commented Jan 10, 2014 at 22:11
  • btw that method won't work as you didn't define a function in the datasource, so setURL wouldn't have existed. The way you have it written above instead just would execute the script inside of your function when it first defines your DataSource. – Goose Commented Jan 10, 2014 at 23:16
  • but i defined it in my dataSource.. – mmmm Commented Jan 11, 2014 at 0:01
  • you had a function inside of your datasource but that doesn't mean it is an extension of the datasource. – Goose Commented Jan 11, 2014 at 0:11
Add a ment  | 

1 Answer 1

Reset to default 5

Once you create the DataSource, set the url value like this:

TasksSource.transport.options.read.url = "Test";
发布评论

评论列表(0)

  1. 暂无评论