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

[Solved] DragNDrop Between Grids In Different User Controls

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 2
Kevin asked on 27 Apr 2009, 07:25 PM
I'm trying to adapt the drag and drop grid sample (with pending orders and shipped orders) to my particular situation and am having some difficulty.

I can't the correct syntax for how to reference each grid's clientid since it is in a user control.  I'm trying as follows:
uc2_RadGrid1.ClientID

But that is not correct.  What is the correct syntax in the javascript below for correctly grabbing a reference to a grid's clientID when it is inside a user control?

Thx!

In my situation, I have each grid in a different user control along with some other items on the screen.  My two user controls each have a RadGri1 grid in them, and they are defined in the page as:

<%@ Register src="ContactGrid.ascx" tagname="ContactGrid" tagprefix="uc2" %> 
<%@ Register src="ContactSelected.ascx" tagname="ContactSelected" tagprefix="uc4" %> 
 

and the script block taken from the sample is:

    <telerik:RadScriptBlock runat="server" ID="scriptBlock">  
 
        <script type="text/javascript">  
            <!--  
                function onRowDropping(sender, args)  
                {   
                    if (sender.get_id() == "<%=uc2_RadGrid1.ClientID %>")  
                    {  
                        var node = args.get_destinationHtmlElement();   
                        if(!isChildOf('<%=uc4_RadGrid1.ClientID %>', node) && !isChildOf('<%=uc2_RadGrid1.ClientID %>', node) )  
                        {   
                            args.set_cancel(true);   
                        }  
                    }  
                    else 
                    {   
                        var node = args.get_destinationHtmlElement();   
                        if(!isChildOf('trashCan', node))  
                        {   
                            args.set_cancel(true);   
                        }  
                        else 
                        {  
                            if (confirm("Are you sure you want to delete this selection?"))  
                                args.set_destinationHtmlElement($get('trashCan'));  
                            else 
                               args.set_cancel(true);   
                        }  
                    }  
                }  
                  
                function isChildOf(parentId, element)  
                {  
                    while(element)  
                    {   
                        if (element.id && element.id.indexOf(parentId) > -1)  
                        {   
                            return true;  
                        }  
                        element = element.parentNode;  
                    }  
                    return false;  
                }  
                -->  
        </script>  
 
    </telerik:RadScriptBlock>  
 

1 Answer, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 27 Apr 2009, 07:35 PM
I got it.  I need to reference them like this:

<%=ContactGrid.FindControl("RadGrid1").ClientID %>


and this:

<%=ContactSelected.FindControl("RadGrid1").ClientID %>

Tags
Grid
Asked by
Kevin
Top achievements
Rank 2
Answers by
Kevin
Top achievements
Rank 2
Share this question
or