My basic question is, every time the Count changes during client-side data binding, it jumps me back to the first page. Is there any way to prevent this?
Here's a more in-depth description of the problem:
I'm using the RadGrid to display messages with client-side data binding. A new message arrives on the server every few seconds. We only keep x hundred messages on the server so once the queue is full old messages fall off the queue as new ones arrive. Therefore using the standard startRowIndex to keep track of where we are in the grid doesn't work for us. What is row 20 in one call might be row 19 a few seconds later as the oldest message falls off the queue. Therefore simply want the next/previous/first/last buttons to jump to the next/previous/first/last group of messages and I'll handle the paging logic with my server code.
Toward that end, I have overridden (using OnItemCreated) the next/previous paging buttons to call my own javascript function for paging -
function myGridPage(radGridId, dir) {
pagingDirection = dir;
$find(radGridId+'_ctl00').page(dir);
}
Then on data binding I do this:
function RadGridMessages_DataBinding(sender, args) {
var myMethodArguments = new Object();
myMethodArguments.pagingDirection = pagingDirection;
myMethodArguments.maximumRows = args.get_methodArguments().maximumRows;
args.set_methodArguments(myMethodArguments);
}
On the server-side I do this:
[WebMethod(EnableSession = true)]
public Dictionary<string, object> GetMessages(string pagingDirection, int maximumRows)
{
<message logic goes here>
Dictionary<string, object> data = new Dictionary<string, object>();
data.Add("Data", messages);
data.Add("Count", totalNumberOfMessages);
return data;
}
Everything seems to work fine, except that the "Count" changes often during the first few hours before the server message queue is full. Every time the Count changes the Telerik client-side code calls set_virtualItemCount() which calls set_currentPageIndex(0). This move me back to the first page (and triggers a rebind).
a. Am I handing the next/previous page in an appropriate way for my situation or is there a better way to do this.
b. How do I prevent set_virtualItemCount() from kicking me back to the first page every time the count changes?
Here's a more in-depth description of the problem:
I'm using the RadGrid to display messages with client-side data binding. A new message arrives on the server every few seconds. We only keep x hundred messages on the server so once the queue is full old messages fall off the queue as new ones arrive. Therefore using the standard startRowIndex to keep track of where we are in the grid doesn't work for us. What is row 20 in one call might be row 19 a few seconds later as the oldest message falls off the queue. Therefore simply want the next/previous/first/last buttons to jump to the next/previous/first/last group of messages and I'll handle the paging logic with my server code.
Toward that end, I have overridden (using OnItemCreated) the next/previous paging buttons to call my own javascript function for paging -
function myGridPage(radGridId, dir) {
pagingDirection = dir;
$find(radGridId+'_ctl00').page(dir);
}
Then on data binding I do this:
function RadGridMessages_DataBinding(sender, args) {
var myMethodArguments = new Object();
myMethodArguments.pagingDirection = pagingDirection;
myMethodArguments.maximumRows = args.get_methodArguments().maximumRows;
args.set_methodArguments(myMethodArguments);
}
On the server-side I do this:
[WebMethod(EnableSession = true)]
public Dictionary<string, object> GetMessages(string pagingDirection, int maximumRows)
{
<message logic goes here>
Dictionary<string, object> data = new Dictionary<string, object>();
data.Add("Data", messages);
data.Add("Count", totalNumberOfMessages);
return data;
}
Everything seems to work fine, except that the "Count" changes often during the first few hours before the server message queue is full. Every time the Count changes the Telerik client-side code calls set_virtualItemCount() which calls set_currentPageIndex(0). This move me back to the first page (and triggers a rebind).
a. Am I handing the next/previous page in an appropriate way for my situation or is there a better way to do this.
b. How do I prevent set_virtualItemCount() from kicking me back to the first page every time the count changes?