DataSource Read called twice

4 posts, 0 answers
  1. Martin
    Martin avatar
    39 posts
    Member since:
    Dec 2011

    Posted 01 Dec 2012 Link to this post

    I am presenting the user with a text box in which they can enter a search term. When the search term changes I call the following script.
    function fillGrid() {
        var grid = $("#Grid").data("kendoGrid");
    Let's say the original search term causes 10 pages to be displayed and that we are viewing page 10. So we are viewing, 190 of 200. And let's say the new search term only produces 100 items, what happens is that the grid is empty and the bottom line indicates we are viewing 190 of 100. Refreshing the grid corrects the problem, but I added the line ";" above to do this automatically. But I have observed that this has the side effect of calling the Controller twice. Generally, I used to refresh the grid. So I am wondering what is the correct way to perform this operation so that I don't make two calls to the database. I guess that every time the grid is changed it updates. Is there a way to turn updating off, make changes to the grid, and then refresh it. 
  2. Nikolay Rusev
    Nikolay Rusev avatar
    2289 posts

    Posted 03 Dec 2012 Link to this post

    Hello Martin,

    I suspect that what you need is to call DataSource.query method and provide the parameters. For example to page on first page with page size 10 and filter expression you will need the following expression:

    <DataSource instance>.query({
     page: 1,
     pageSize: 10,
     filter: { operator: ">", field: "OrderID", value: 10248 }

    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Linda
    Linda avatar
    1 posts
    Member since:
    Jul 2017

    Posted 23 Aug 2017 in reply to Nikolay Rusev Link to this post


    I have the same problem and try with <DataSource instance>.query .... but doesn't work

    This is my code:

     // Restore the selected grid page.
                    var pageToSelect = 0;
          'change', function (e) {
                        var currentPage = || 1,
                            totalPages = gridSource.totalPages();

                        // < totalPages ? currentPage : totalPages);
                        pageToSelect = currentPage < totalPages ? currentPage : totalPages;

                        page: pageToSelect,
                        pageSize: 10,
          ; // READ

  4. Preslav
    Preslav avatar
    591 posts

    Posted 25 Aug 2017 Link to this post

    Hi Linda,

    I believe that this behavior is caused by the read method of the dataSource. Remove the last line of the provided code and only a single read will be called.

    If this is not the case, in order to continue my investigation, please send as an isolated Dojo that clearly replicates the issue. I will use it to fully understand the scenario and provide assistance to the best of my knowledge.

    Progress Telerik
    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.
Back to Top