DataSource Read called twice

2 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
    2287 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!
Back to Top