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

[Solved] One dataSource to rule them all.

2 Answers 129 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Phil H.
Top achievements
Rank 2
Phil H. asked on 15 Sep 2014, 11:17 PM
Hi:

I was looking for a way to have one dataSource for a table but have multiple views.  View could be a grid, listView and details view.  But to have paging in the grid I would need to extend the base dataSource.  I am currently, I am doing that with my models using the define.  I am looking for a similar thing for dataSources but having variations for paging, etc.

Phil  

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 17 Sep 2014, 02:54 PM
Hello Phil,

Using a shared dataSource might create behaviors that you are not looking for - for example if you have ListView and Grid bound to the same DataSource instance object then paging the Grid will make the ListView page as well.

http://demos.telerik.com/kendo-ui/datasource/shared-datasource

If you want to have the configuration at one place it is possible, but you should have different instances of the dataSource (when object literal is passed to the dataSource the widget creates the dataSource internally).

e.g.
var dsConfig = {
       transport: {
               read: {
                       url: "someUrl"
               }
       },
       schema: {
             model: ...
       }
}
 
$("#listView").kendoListView({
          dataSource: dsConfig
          //... other options
})
 
$("#grid").kendoListView({
          dataSource: dsConfig
          //... other options
})


Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Phil H.
Top achievements
Rank 2
answered on 18 Sep 2014, 12:52 PM
Hi All:

I am currently placing table specific in it's own table container as follows (data source is generic):
TableCont = {
  ...
}
TableCont.ProdModel = kendo.data.Model.define({
  ...
});
TableCont.prodDataSource = new kendo.data.DataSource({
  ...
});
Then in specific implementation, I am doing the following:
TableCont.prodDataSource.pageSize(5);
 
$('#grid').kendoGrid({
  dataSource: TableCont.prodDataSource,
  ...
});

Phil
Tags
Data Source
Asked by
Phil H.
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Phil H.
Top achievements
Rank 2
Share this question
or