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

Create local Data Source from remote Data Source data

2 Answers 622 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 16 Feb 2017, 04:27 PM

Apologize for the noobie question.

I am trying to populate both a grid and a chart with data from the same remote data source.  However, since the chart will need it's data grouped, but the grid will not, it looks like I need to have two separate data sources, each one making a call to the database.

In an attempt to have only a single call to the database, I am trying to create a LOCAL data source by reading data from the REMOTE data source once it has been returned.  I'm curious if this is even possible, and if so, how I would do this.  This is what I'm currently trying. "remoteDataSource is working fine, but "localDataSource" doesn't seem to be bringing back any data.

var remoteDataSource = new kendo.data.DataSource({
 transport: {
         read: {
         url: "connect.php",
         type: "get",
         dataType: "json"
         }
 },
     schema: {
  model: {
   fields: {
    WONUM: { type: "string" },
    RN: { type: "number" },
    DESCRIPTION: { type: "string" },
    STATUS: { type: "string" },
    STATUSDATE: { type: "datetime" },
    MONTH_DT: { type: "string" },
    YEAR_DT: { type: "string" },
    WORKTYPE: { type: "string" },
    ASSETNUM: { type: "string" },
    GMD_DEPT_CODE_ASSET: { type: "string" },
    LOCATION: { type: "string" },
    GMD_DEPT_CODE_LOC: { type: "string" }
   }
  }
 },
});
        
var localDataSource = new kendo.data.DataSource({
 data: remoteDataSource
});

2 Answers, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 20 Feb 2017, 10:02 AM
Hi Mark,

There are few different ways to achieve the required functionality.

- Use the Kendo UI Grid dataBound event to set the data source of the Kendo UI Chart

http://dojo.telerik.com/oGiDA

- Use the Kendo UI Data Source change event to obtain the data and then pass it to the local data source instance

change event: http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events-change 
data method: http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data
Demo: http://dojo.telerik.com/EjuNi

- Use the Kendo UI Data source read() method and assign the data in the promise returned by the read()

read method: http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-read

- Use the requestEnd of the remote data source

requestEnd event: http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events-requestEnd

I hope this helps.

Kind Regards,
Alex Hajigeorgieva
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mark
Top achievements
Rank 1
answered on 20 Feb 2017, 08:46 PM
Thank you very much Alex!
Tags
Data Source
Asked by
Mark
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Mark
Top achievements
Rank 1
Share this question
or