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

RadGrid Client DataBound - extra events

2 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Murray
Top achievements
Rank 1
Murray asked on 14 Jan 2009, 09:37 PM
On my main page:
Javascript:
my PageMethod call:
PageMethods.GetDataAndCount(findString, sortSQL, sessionKey, sortName, pageIndex, pageSize, qmarkUpdateGrid);

My Javascript callback function:
function qmarkUpdateGrid(result)
{
    var data = result.data;
    var count = result.count;
    // selectedRow is within resultset not current page
    var selectedRow = result.selectedRow;
    var pageIndex = result.pageIndex;
    var searchLabel = result.searchLabel;
    var sl = $get("<%= labGetItem.ClientID %>");
    var init = sl.getAttribute("init");
    sl.innerHTML = searchLabel;
    var mtv = $find("<%= grdList.ClientID %>").get_masterTableView();
    mtv.set_dataSource(data);
    mtv.dataBind();
    mtv.set_virtualItemCount(count);
    mtv.set_currentPageIndex(pageIndex);
    if (selectedRow < 0)
    {
        mtv.clearSelectedItems();
    }
    else
    {
        var rowIndex = selectedRow - (mtv.get_pageSize()*pageIndex);
        mtv.get_dataItems()[rowIndex].set_selected(true);
    }
}

My web method returns:
    result.data => 1 page of data
    result.count => total rows for all pages
    result.selectedRow => if this was a find request then row number within all pages
    result.pageIndex => if this was a find request then it might be on different page (data contains correct page)
    result.searchLabel => search label will change depending on what col search is for

The problem i have is when i do a find request and it goes to a different page than what was displayed at time of event, It fires another OnCommand event when i set currentPageIndex on grid control?

I need logic to stop this extra event. I already the correct page in grid.

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 15 Jan 2009, 07:33 AM
Hi Murray,

In order to suppress the second command event when setting currentPageIndex  you should use set_currentPageIndex but passing true as second parameter.

Please give it a try and let us know if this helps.

Regards,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Murray
Top achievements
Rank 1
answered on 15 Jan 2009, 01:01 PM
Thanks Rosen, That worked
Tags
Grid
Asked by
Murray
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Murray
Top achievements
Rank 1
Share this question
or