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

To access page row on client

2 Answers 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jane Mathew
Top achievements
Rank 1
Jane Mathew asked on 10 Mar 2010, 12:06 PM
Hi,

I'm not an expert with Telerik controls and am stuck with this. I need to somehow access the page row for a RadGrid from client side. Is this even possible?

TIA for any help!

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Mar 2010, 07:48 AM

Hello Jane,

I tried following approach in order to access the pager item from client side:

Pass the ClientID of pager combobox from server code and save in a HiddenField control. From client event handler access the HiddenField and get the combo client object. Then using the parentNode property, get access to pager item. Here is the code that I tried.

aspx:

 
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridPagerItem)  
        {  
            RadComboBox combo = (RadComboBox)(e.Item as GridPagerItem).FindControl("PageSizeComboBox");  
            HiddenField1.Value = combo.ClientID;  
        }  
    } 

javascript:

 
    function getPager() {  
        var hf = document.getElementById("HiddenField1");  
        var combo = document.getElementById(hf.value);  
        var pager = combo.parentNode.parentNode.parentNode;  
        pager.style.backgroundColor = "Red";  
    } 

-Shinu.

0
Valery
Top achievements
Rank 2
answered on 11 Mar 2010, 02:27 PM
The following function looks for a row containing the "rgPager" class in the footer of the grid:
function GetGridPagerRow(gridClientId) { 
    var grid = $find(gridClientId); 
    var masterTableView = grid.get_masterTableView(); 
    var footerRows = masterTableView.get_element().tFoot.rows; 
    for (var i = 0; i < footerRows.length; i++) { 
        var row = footerRows[i]; 
        if (Sys.UI.DomElement.containsCssClass(row, 'rgPager')) { 
            return row; 
        } 
    } 
 
    return null

Hope it helps,
Valery.
Tags
Grid
Asked by
Jane Mathew
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Valery
Top achievements
Rank 2
Share this question
or