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

Datasource read called twice if emtpy

1 Answer 155 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
moosh
Top achievements
Rank 1
moosh asked on 16 Sep 2019, 06:15 AM

Hi,

Sorry in advance but I have no example in hand now by writing post.
I will try to explain clearly.

I have a MVVM implementation with a fruits property bound to a selectDropdown widget.
This property is an empty array by default (fruits: [])

I have a dataSource dsource instance which call a remote endpoint.
I call the fetch method manually and define a callback function which do some tasks :

- dsource.filter(...);
- dsource.sort(...);
- viewModel.set('fruits', dsource);

(Note that I didn't applied dsource as default value of my fruits property cause of specific mvvm implementation)

 

My issue is :
Everything works well unless if my dsource return empty data.
In this case, filter, sort or set dsource to viewModel are calling the read method a second time.
It can call the read method 4 times (1 for first call, 1 for filter, 1 for sort and 1 for view model set method).

Why ? it should not cause my dsource has been instantiated and call a first time...

Thanks :)

moosh

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 18 Sep 2019, 05:40 AM
Hi, Moosh,

Thank you for the explanations of your scenario and trying out the Kendo UI suite.

The Kendo UI DataSource is expected to make a request for sort() and filter() calls as they are used one after the other.

If you want to make a combined single call with certain sort, filter, group etc, you should use the query method instead:

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/methods/query

Let us know in case you have further questions.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Data Source
Asked by
moosh
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or