set_virtualItemCount hits database twice

2 posts, 0 answers
  1. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 27 Mar 2009 Link to this post

    Hi,

    I have a grid and paging, filtering enabled. I use client-side databinding and client-side history management. When I run grid, paging and filtering works fine, but when I push browsers back button problem begins.

    To see the problem lets look at history.
    1 - first load; pageindex = 0, filter = ""
    2- push next page button; pageindex = 1, filter =""
    3- filter (lets say age column "age < 21"); pageindex = 0 (this is normal, item count changed [27] and pager must be on first page), filter="age < 21"
    4- now push back button, pageindex 1, filter ="" read by history control, PageMethods.GetData(dyanmicLinqQuery, sortExpressions.toString(), pageindex, pagesize, updateGrid, webServiceCallFailed) called, and desired data / item count [1152] returns with pageindex=1, and filter="". So I can set mastertableview's pageindex and pager will show "Page 2 of x" which is ture (step 2, pageindex=1). Now updateGrid event fired

    function updateGrid(result) { 
    tableView.set_dataSource(result.Data); 
    tableView.set_virtualItemCount(result.rowCount); 
    tableView.dataBind(); 
    }  


    now it comes to line set_virtualItemCount with itemcount of 1152. set_virtualItemCount internally compares previous item count [27] with current one [1152]. If there is a difference then it calls page(0) method and sets pageindex 0 (actually this could be normal for any other scenarios), and this call also fires my RadGrid1_Command which hits datacontext again. And at the end, pageindex=0 (but must be 1 according to step 2), and there is 2 datacontext hits.
     
    So how can I by-pass page(0) event which fired by set_virtualItemCount internally?

    Thanks in advance


    PS: I am using Q1 2009
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 31 Mar 2009 Link to this post

    Hi barbaros,

    You may try using onCommand event to cancel the second rebind. You may raise a flag before the call to
    set_virtualItemCount and check for it inside onCommand event handler.  

    Greetings,
    Rosen
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top