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

ContextMenu with nested grid

3 Answers 95 Views
Menu
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 13 Jun 2011, 06:53 PM
Hi,

Is it possible to attach a context menu to a nested grid ? I currently have a radGrid with a nestedGrid and I use the following code to attach a menuContext

function RowContextMenu(sender, eventArgs) {
    var menu;
    var ownerTable = eventArgs.get_tableView();
 
    if (ownerTable.get_name() == "Grid") {
        menu = $find("<%=RadContextMenuUser.ClientID %>");
    }
    else if (ownerTable.get_name() == "NestedGrid") {
        menu = $find("<%=RadContextMenuUsersRole.ClientID %>");
    }

    var evt = eventArgs.get_domEvent();
 
    if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") {
    return;
    }
 
    var index = eventArgs.get_itemIndexHierarchical();
    document.getElementById("radGridClickedRowIndex").value = index; 
    document.getElementById("radGridClickedTableId").value = ownerTable._data.UniqueID;
 
    sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);

For the "parent" grid, it works really great, but it doesn't work for the nestedGrid. In fact, I have the following error : 
Cannot call method 'get_element' of undefined.  

So, anyone may help me please ?

3 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 13 Jun 2011, 07:55 PM
Hi,

Finally, try this and it work :

var gridIndex = index.split(":", 1);
index = index.split("_");
sender.get_masterTableView().selectItem(sender.get_detailTables()[gridIndex].get_dataItems()[index[1]].get_element(), true);


Edit : In fact, it seem it doesn't work that  well. In fact, in will explain again my problem, cause I realized I really wasn't clear. What I want is, when I right click on a item on the nested grid (or detail table), the item become selected and a context menu pop up. I know how to attach the context menu to the item of the nested grid, but I don't quite know how to selected this item. The code I put in this post doesn't work well, cause it doesn't un-select the previous selected item. So, my nested grid, even if AllowMultiRowSelection is set to false, allow to selected many item by this way. So, may someone help me please.

David Lefaivre
0
Accepted
Daniel
Telerik team
answered on 16 Jun 2011, 08:41 PM
Hello David,

You can clear the selected items before selecting a new one. I confirm it is possible to select more than one item via the client-side API.
var masterTable = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
masterTable.clearSelectedItems();

Kind regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
David
Top achievements
Rank 1
answered on 20 Jun 2011, 03:56 PM
Thank you, it work.

But, in fact, it wasn't get_masterTableView(), but get_detailTables(). 
Tags
Menu
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or