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

Context Menu - Javascript GetDataKeyName of Parent

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 03 Sep 2009, 08:56 PM
Hello all.  I am trying to get a datakeyname from the parent
of a child table when the Context Menu is displayed.  I am
having a difficult time trying to figure this out.  Any ideas?
Thanks.

// Abbreviated function for ease of reading  
function ShowContext(sender,args){  
var menu = $find("GridContextMenu");  
var selectedindex = args.get_itemIndexHierarchical();  
 
//Not sure about below  
var parentindex = sender.get_parentView().getDataKeyNames("EventId");  
 
menu.show(args.get_domEvent());  


Joshua

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Sep 2009, 08:17 AM
Hi Josh,

Give a try with the following approach and see whether it helps.

ASPX:
 
        <telerik:RadGrid ID="RadGrid2" runat="server" ShowFooter="true" AllowPaging="True" PageSize="7"   > 
                <MasterTableView CommandItemDisplay="Top"  
   ClientDataKeyNames="ProductID" > 
                    <Columns> 
                      ... 
                    </Columns> 
                    <DetailTables> 
                         
                        ... 
                    </DetailTables> 
                </MasterTableView> 
                <ClientSettings> 
                    <ClientEvents OnRowContextMenu="ShowContext" OnRowCreated="OnRowCreated" /> 
                </ClientSettings> 
            </telerik:RadGrid> 

JS:
 
 
<script type="text/javascript"
 function ShowContext(sender, eventArgs) 
 { 
  var selectedindex = eventArgs.get_itemIndexHierarchical();   
  var table = eventArgs.get_tableView();  
  var ParentRow=table.get_parentRow(); 
  if(ParentRow!=null
  { 
   var masterTable = $find("<%= RadGrid2.ClientID %>").get_masterTableView(); 
   var currentrow = masterTable.get_dataItems()[ParentRow.sectionRowIndex]; 
   alert(currentrow.getDataKeyValue("ProductID")) 
  } 
 
</script> 
 


Thanks
Shinu
Tags
Grid
Asked by
Josh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or