Problem with GridButtonColumn and RadAlert in Grid

4 posts, 0 answers
  1. Pandu
    Pandu avatar
    38 posts
    Member since:
    Sep 2009

    Posted 28 Apr 2010 Link to this post

    Dear Telerik Team,

    I have a page with RadGrid control which has some bound columns and GridButton column which is for delete (having inner) item in grid. Open a popup when click on command item link button and it has a tabstrip which has three tabs. In third tab we have a grid which has to ask radconfirm on OnClient event when click on Generate command item Link button. If OK it has to fire event and do some operation. I tried with all the ways from the articles,forum and documentation source but i didn't. At last i tried with the below script which is working fine but i am unable to fire Delete in Grid.
    <script language="javascript" type="text/javascript">   
            var oldConfirm = radconfirm;      
            window.radconfirm = function(text, mozEvent, oWidth, oHeight, callerObj, oTitle)      
            {      
                var ev = mozEvent ? mozEvent : window.event; //Moz support requires passing the event argument manually      
                //Cancel the event      
                ev.cancelBubble = true;      
                ev.returnValue = false;      
                if (ev.stopPropagation) ev.stopPropagation();      
                if (ev.preventDefault) ev.preventDefault();      
                      
                //Determine who is the caller      
                var callerObj = ev.srcElement ? ev.srcElement : ev.target;      
         
                //Call the original radconfirm and pass it all necessary parameters      
                if (callerObj)       
                {      
                    //Show the confirm, then when it is closing, if returned value was true, automatically call the caller's click method again.      
                    var callBackFn = function (arg)      
                    {                 
                        if (arg)      
                        {                 
                            callerObj["onclick"] = "";                
                            if (callerObj.click) callerObj.click(); //Works fine every time in IE, but does not work for links in Moz      
                            else if (callerObj.tagName == "A") //We assume it is a link button!      
                            {                                                             
                                try     
                                {      
                                    eval(callerObj.href)      
                                }      
                                catch(e){}      
                            }      
                        }      
                    }      
      
                    oldConfirm(text, callBackFn, oWidth, oHeight, callerObj, oTitle);    
                }      
                return false;      
            }     
        </script>  

    Can you please go through this issue and give me a better solution.

  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 03 May 2010 Link to this post

    Hello Pandu,

    You could try firing a custom RadGrid's command from the client with the following code snippet:
    JavaScript
    var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
    masterTable.fireCommand("MyCustomCommand", RadGridItemID);

    Then on RadGrid.ItemCommand event handler you could check if the fired command is the custom command and perform delete operation:
    void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == "MyCustomCommand")
        {
             int itemID = Convert.ToInt32(e.CommandArgument.ToString());
             // Delete item with ID equals to value in itemID.
             ...
        }
    }

    I hope this helps.

    Kind regards,
    Radoslav
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 21 Jul 2011 Link to this post

    Hi,
    I'm using a external Linkbutton (in a user control) to delete a selectedrow in a RadGrid, It works fine.
    I add onCLientClick a call to a javascript function to show a RadConfirm message before execute the delete command.. but i never get show the radconfirm... seems that it doesn't work whith the  item.FireCommandEvent . Is this possible ?
    I'd like to keep the radconfim in a javascript function not inside codebehind.

    code:
    Button:
    <asp:ImageButton ID="imbDelete" runat="server" AlternateText="Elimina" CausesValidation="False" Enabled="false"
                        ImageUrl="~/Images/delete.png" CssClass="pulsante_disabled"  OnClick="imbDelete_Click" OnClientClick="return ConfirmationDelete(this);"  /> 
      
    Code behind:
    foreach (GridDataItem item in _rdgPopup.MasterTableView.GetSelectedItems())
                            item.FireCommandEvent("DeleteSelected", String.Empty); 
      
    javascript code ( external file )
      
      
     function ConfirmationDelete(clickedButton)
      {
          alert('confirm');
         function confirmHandler(args)
          {
              if (args == true)
              {
                  __doPostBack(clickedButton.name, '');            
             }
         }
      
         radconfirm(vQuestionText, confirmHandler, 250, 100, null, vTitle);
         return false;
     }


    Thanks!!
  5. Marin
    Admin
    Marin avatar
    1044 posts

    Posted 26 Jul 2011 Link to this post

    Hello,

     I checked your code and it was working correctly on my end. You can see it in the attached sample page. You should check whether you have RadWindowManager on the page if it is configured properly.

    Regards,
    Marin
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top