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

problem with nested radgrid

1 Answer 41 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roukaya
Top achievements
Rank 2
Roukaya asked on 09 Jul 2012, 09:16 AM
Hello all ,

i've nested radgrid : Radgrid2 into radgrid1

and i want to get the selected row id when "onRowClick" event fires ,

i wrote this js function :   

 function RowClick(sender, eventArgs) {
        var grid = sender;
        var MasterTable = grid.get_masterTableView();
        var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        var cell = MasterTable.getCellByColumnUniqueName(row, "Forum_id");
        alert(cell.innerHTML);
    }
 

the client side code is :
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true"  OnItemCommand="RadGrid1_ItemCommand" >           
                    <MasterTableView>
                    <NestedViewTemplate>
                        <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" OnNeedDataSource="RadGrid2_NeedDataSource">                                 
                               <ClientSettings>
                
        <ClientEvents OnRowClick="RowClick"/>
    </ClientSettings>
                       </telerik:RadGrid>
      
                    </NestedViewTemplate>                    
                </MasterTableView>
                <ClientSettings>     
        <ClientEvents OnRowClick="RowClick"/>
    </ClientSettings>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>

when i click on a row of radgrid1 , js function works rightly .
but when i click on a row of radgrid2 , 2 alert messages appear : the first one gives me the right selected id (what i want ) but the other one gives me the the selected index ..  

how to prevent "onRowClick" event to fire 2 times when i click on radgrid2??  

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 10 Jul 2012, 05:44 AM
Hi Roukaya,

From you description it is not clear what you are trying to achieve. However, I will give you a couple of notes that might prove helpful.

1. In the args event object you have all the referenced objects you need to get any information about the item clicked - args.get_item(), args.get_gridDataItem(), args.get_tableView() etc. And this will be the item/table view of the grid clicked.

2. If the event is called for the parent grid as well, just prevent is bubbling:

var evt = args.get_domEvent().rawEvent;
  
if (evt.preventDefault)
{
  
   evt.preventDefault();
   evt.stopPropagation();
  
}
  
evt.cancelBubble = true;
evt.returnValue = false;
  
  
return false

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Roukaya
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
Share this question
or