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

Controlling the datasource read

2 Answers 263 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Sune
Top achievements
Rank 1
Sune asked on 08 Oct 2015, 10:47 AM

Hi

We are programatically configuring an odata datasource. We setup filters, group and sort and columns.

The datasource appears to be issueing two reads during this process.

 

The code is something like:

ds.filter(filter);

ds.group(group);

ds.sort(sort);

At no point are we explicitly calling ds.read() but the above statements trigger 2 consecutive reads, the first of which is triggered on the ds.filter(filter) and serves no purpose at all. 

We would like to prevent the reads until the datasource has been fully configured.

Is this possible to disable the first read and control reads explicitly?

 

Thanks, 

Sune

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 12 Oct 2015, 05:32 AM
Hello Sune,

This behavior is expected when using server operations, as each change in the sorting, filtering and etc options should lead to a Read request in order to keep the DataSource updated. In this case I  would suggest using the query method instead, as it allows you to set all those options at the same time, avoiding unnecessary requests.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Sune
Top achievements
Rank 1
answered on 12 Oct 2015, 07:58 AM

Hi Thanks! This solved it nicely. 

I tried several hacks, replacing the read() with a bogus do-nothing method - didn't work. Then I tried reinitializing the datasource from scratch with the correct config from the start.

The last idea may actually be a good solution also but in my case it's a bigger rewrite.

Tags
Data Source
Asked by
Sune
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Sune
Top achievements
Rank 1
Share this question
or