radgrid with RadContextMenu

3 posts, 0 answers
  1. Roger
    Roger avatar
    183 posts
    Member since:
    Sep 2007

    Posted 13 Mar 2009 Link to this post

    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. Roger
    Roger avatar
    183 posts
    Member since:
    Sep 2007

    Posted 15 Mar 2009 Link to this post

    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
  3. Monalisa
    Monalisa avatar
    35 posts
    Member since:
    May 2009

    Posted 14 Jul 2009 Link to this post

    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.

Back to Top