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

set_virtualItemCount hits database twice

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Barbaros Saglamtimur
Top achievements
Rank 1
Barbaros Saglamtimur asked on 27 Mar 2009, 03:23 PM
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

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 31 Mar 2009, 02:40 PM
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.
Tags
Grid
Asked by
Barbaros Saglamtimur
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or