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

DataSource triggered twice, once with and once without filters

3 Answers 973 Views
Grid
This is a migrated thread and some comments may be shown as answers.
rugydp
Top achievements
Rank 1
rugydp asked on 17 Nov 2014, 03:05 PM
I have successfully create a Grid with an external datasource. Paging and filtering is activated. Paging without filtering works fine, filtering without paging works fine as well.

What doesn't work is paging a filtered grid. When for example I click on page two, the XHR request is send twice, once with filter parameters  applied, once without, almost at the same time. The filtered results gets replaced by an unfiltered one.

Request with filter:
http://localhost:8080/web/app_dev.php/service/kundenstatistik/read?take=25&skip=25&page=2&pageSize=25&filter%5Blogic%5D=and&filter%5Bfilters%5D%5B0%5D%5Bfield%5D=auvtnr&filter%5Bfilters%5D%5B0%5D%5Boperator%5D=eq&filter%5Bfilters%5D%5B0%5D%5Bvalue%5D%5B%5D=117

Request without filter:
http://localhost:8080/web/app_dev.php/service/kundenstatistik/read?take=25&skip=25&page=2&pageSize=25

Can somebody explain why two different requests are triggered by the pager?

Thank you very much

01.var dataSource = new kendo.data.DataSource({
02.        type: "get",
03.        transport: {
04.            read: { url: "service/kundenstatistik/read",
05.                dataType: "json"
06.            }
07.        },
08.        schema: {
09.            data: "data",
10.            total: "total"
11.        },
12.        pageSize: 25,
13.        serverPaging: true,
14.        serverFiltering: true,
15.        serverSorting: true
16.    });
17.       
18.     $("#grid").kendoGrid({
19.        scrolable: false,
20.        filterable: true,
21.        sortable: true,
22.        pageable: true,
23.        columns: [
24.            { title: "No.", field: "aukunr", filterable: false },
25.            { title: "PLZ", field: "plz", filterable: false },
26.            { title: "Ort", field: "ort", filterable: false },
27.            { title: "Land", field: "land", filterable: false },
28.            { title: "ABCD", field: "abcd", filterable: false },
29.            { title: "K-Grp", field: "aukugrp", filterable: false },
30.            { title: "Vertr.", field: "auvtnr1", filterable: false },
31.            { title: "Sp", field: "sp", filterable: false },
32.            { title: "Umsatz", field: "umsatz", filterable: false, format: "{0:c}", attributes:{ class:"right" } },
33.            { title: "Umsatz CHF", field: "umsatz", filterable: false, format: "{0:c}", attributes:{ class:"right" } }
34.        ],
35.        dataSource: dataSource
36.    });







3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 19 Nov 2014, 09:18 AM
Hello ,

This  isn't known behavior to us. Clicking on pager will trigger request which will have current state of the data source - i.e all filter/sort/group etc. expressions + current page and page size.

You can see it working in the following example by inspecting the browser console: http://demos.telerik.com/kendo-ui/grid/remote-data-binding.

Can you isolate the behavior in example so we can test it locally and assist you further.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
rugydp
Top achievements
Rank 1
answered on 20 Nov 2014, 07:23 AM
Thank you, Nikolay. I converted the grid and datasource to the PHP wrapper and now everything works as expected. I don't see many differences to my code. One major difference is that I put my code into a javascript file and into the $(document).ready() area. That might have triggered some code twice, although the page was only loaded once?

Well, now it works and we wanted to use the PHP Wrappers anyways. It's just a pity it's not included in the DevCraft Complete bundle. I will have to convince my boss to throw more money at you ;)

Regards
Rugy




0
Nikolay Rusev
Telerik team
answered on 21 Nov 2014, 04:13 PM
Hello Ruggero,

`One major difference is that I put my code into a javascript file and into the $(document).ready() area. That might have triggered some code twice, although the page was only loaded once? ` - this shouldn't be the reason either. If you review the code in the code viewer in the example I've send you, you will see that widget initialization is wrapped in document.ready handler. This is to ensure that all scripts are already loaded when attempt to initialize any widget.

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