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

[Solved] Bug - dataSource.page(s.page), dataSource.fetch()

10 Answers 209 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
leblanc
Top achievements
Rank 1
leblanc asked on 16 Apr 2014, 05:48 PM
var s = uiStateService.Get(stateKey);
if (s != null) {
    g.dataSource.pageSize(s.pageSize);
    g.dataSource.sort(s.sort);
    g.dataSource.filter(s.filter);
    g.dataSource.page(s.page);
}
 
internal.state = 2;
g.dataSource.fetch(function () {
    // warning kendo bug - has to make a request then I update the page on the callback
    g.dataSource.page(s.page);
});



first fetch()
http://localhost:7073/api/core/mymodel?sort=&page=1&pageSize=5&group=&filter=Name~startswith~%27c%27&_=1397664616933

second fetch() to to change of page in callback
http://localhost:7073/api/core/mymodel?sort=&page=2&pageSize=5&group=&filter=Name~startswith~%27c%27&_=1397664616934


why doesn't the correct page # get sent on the first request along with the other parameters?

a little clunky to make 2 requests.

10 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 17 Apr 2014, 08:29 AM
Hi leblanc,

I'm not sure if I understood exactly what you are trying to achieve. However, as you may know, when server operations are enabled, calling every one of the pageSize, sort, filter, page, group etc. methods will issue an individual request to the server with the current state of the Grid's operation descriptors. Therefore, the code within the if block, may (if called with non null argument) issue four separate requests. In case you need to set the more then one of those operation descriptor at once, the use of query method is more appropriate.

var s = uiStateService.Get(stateKey);
g.dataSource.query(s);


Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
leblanc
Top achievements
Rank 1
answered on 17 Apr 2014, 07:36 PM
by default it would have issued multiple requests but I preventedDefault()

g.dataSource.bind("requestStart", function (e) {
    if (internal.state === 1) {
        e.preventDefault();
    }
});



given s is:
var state = {
    page: g.dataSource.page(),
    pageSize: g.dataSource.pageSize(),
    sort: g.dataSource.sort(),
    filter: g.dataSource.filter()
};

after it's been deserialized at a future time.



g.dataSource.query(s);

still suffers from not sending correct page #.  So the bug is that I have to make two requests for the correct page number to finally take effect.


0
Rosen
Telerik team
answered on 18 Apr 2014, 07:10 AM
Hi leblanc, 

As you are preventing the requestStart event, the changes made to DataSource operation descriptors state are not persisted. Thus, calling page method will not modify the page index.

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
leblanc
Top achievements
Rank 1
answered on 25 Apr 2014, 07:54 PM
all the other parameters are persisted except page #.

see internal.state === 1 check on requestStart


internal.state = 2;
g.dataSource.fetch(function () {
    // warning kendo bug - has to make a request then I update the page on the callback
    if (s != null) {
        g.dataSource.page(s.page);
    }
});
0
leblanc
Top achievements
Rank 1
answered on 25 Apr 2014, 07:55 PM
without using requestStart canceling - just using

g.dataSource.query(s);

still suffers from not sending correct page #.  So the bug is that I have to
make two requests for the correct page number to finally take effect.
0
Rosen
Telerik team
answered on 28 Apr 2014, 07:21 AM
Hi leblanc,

Could you please provide a test page in which the issue you are experiencing can be observed locally. You may use Kendo UI Dojo to build the page. 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
leblanc
Top achievements
Rank 1
answered on 28 Apr 2014, 09:19 PM
I will. Can you provide me a remote datasource I can bind to the grid using the asp.net mvc server side paging, filtering, sorting?
0
Rosen
Telerik team
answered on 29 Apr 2014, 07:26 AM
Hi leblanc,

I'm afraid that there is not such public service available. Unfortunately, if the issue in question is only reproducible when UI for ASP.NET MVC is used, it will be required to prepare a ASP.NET MVC application instead of a Kendo UI Dojo page. 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
RRT
Top achievements
Rank 1
answered on 07 Nov 2014, 08:30 PM
leblanc is correct. I am experiencing this with paging, and in my case I am calling an API for the datasource with a quota for calls, so calling the API twice as much is troubling.
0
Rosen
Telerik team
answered on 10 Nov 2014, 08:51 AM
Hi RRT,

Maybe you could provide a small sample in which this issue can be observed locally? 

Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Data Source
Asked by
leblanc
Top achievements
Rank 1
Answers by
Rosen
Telerik team
leblanc
Top achievements
Rank 1
RRT
Top achievements
Rank 1
Share this question
or