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

radgrid with RadContextMenu

2 Answers 258 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 1
Roger asked on 13 Mar 2009, 11:15 AM
Hi,
I have a RadContextMenu attached to a RadGrid with 3 options: add, edit and delete the selected row. I use the "OnClientItemClicking" othe RadContextMenu to enable/disable some properties depending on a datakey of the selected row. This works fine as well...until...
  1. if I use the method RadGrid.get_masterTableView().showInsertItem() the editform shows beautifuly
  2. if I then cancel the insert operation, I can't get the radcontextmenu back again. Instead of firing the "OnClientItemClicking" when I right-click the grid it fires the "OnRowContextMenu" event of the grid and bypasses the "OnClientItemClicking"

What I am trying to do is automatically select the first row (if there is one) after the cancel link of the insert has been selected. I can't seem to catch the event client side and am using the Server Side CancelCommand to set a flag that selects the first row in the PreRender event. This works but then I lose the context menu.

Any Ideas?

Regards
Roger

2 Answers, 1 is accepted

Sort by
0
Roger
Top achievements
Rank 1
answered on 16 Mar 2009, 04:21 AM
Hi again,

found the problem...I didn't link the radcontext menu with the radgrid in the radajaxmanager...once done all is ok

Regards
Roger
0
Monalisa
Top achievements
Rank 1
answered on 14 Jul 2009, 07:11 AM
Hi,
I have a radgrid with RadContextMenu having 3 options: Open, Edit, Delete.
When I click on Open/Edit the popup does not open. How to the popup in edit/open mode when I click on menu item.
Following is the code snippet.

<

telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

 

 

<script type="text/javascript" language="javascript">

 

 

function ShowEditForm(id, rowIndex) {

 

 

var grid = $find("<%= RadGrid1.ClientID %>");

 

 

var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();

 

grid.get_masterTableView().selectItem(rowControl,

true);

 

window.radopen(

"ABC.aspx?ID=" + id, "UserListDialog");

 

 

return false;

 

}

 

function ShowInsertForm() {

 

window.radopen(

"ABC.aspx", "UserListDialog");

 

 

return false;

 

}

 

function RowDblClick(sender, eventArgs) {

 

window.radopen(

"ABC.aspx?ID=" + eventArgs.getDataKeyValue("PK_ICD_CPT_CODE_ID"), "UserListDialog");

 

}

 

function refreshGrid(arg) {

 

 

if (!arg) {

 

$find(

"<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");

 

}

 

else {

 

$find(

"<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");

 

}

}

 

function RowContextMenu(sender, eventArgs) {

 

 

var menu = $find("<%=RadMenu1.ClientID %>");

 

 

var evt = eventArgs.get_domEvent();

 

 

var index = eventArgs.get_itemIndexHierarchical();

 

document.getElementById(

"radGridClickedRowIndex").value = index;

 

menu.show(evt);

evt.cancelBubble =

true;

 

evt.returnValue =

false;

 

 

if (evt.stopPropagation) {

 

evt.stopPropagation();

evt.preventDefault();

}

sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(),

true);

 

}

 

 

</script>

 

 

</telerik:RadCodeBlock>

.cs page
-----------------

 

 protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
        {
            #region Commented because open/edit not working properly
            int gridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);
            int pkId = Convert.ToInt32(RadGrid1.Items[gridClickedRowIndex].GetDataKeyValue("PK_ICD_CPT_CODE_ID"));

            switch (e.Item.Text)
            {
                case "Edit":
                   RadMenu1.Attributes.Add("OnClick", "javascript:return ShowEditForm('{0}','{1}');");
                  
                   RadGrid1.Rebind();
                    break;
                case "Open":
                     RadMenu1.Attributes.Add("OnClick", "javascript:ShowInsertForm();");
                   RadGrid1.Rebind();
                    break;
                case "Delete":

                    string delete = "update table set row_status = 0 where ID = " + pkId + "";
                    SqlHelper.ExecuteNonQuery(Utilities.GetConnectionString, CommandType.Text, delete);
                    RadGrid1.Rebind();
                    break;

            }


could any body help me.

Tags
Menu
Asked by
Roger
Top achievements
Rank 1
Answers by
Roger
Top achievements
Rank 1
Monalisa
Top achievements
Rank 1
Share this question
or