<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DragAndDropVB.aspx.vb" Inherits="DragAndDropVB" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:radscriptmanager id="RadScriptManager1" runat="server">
        </telerik:radscriptmanager>
        <telerik:radajaxloadingpanel id="RadAjaxLoadingPanel1" runat="server" />
        <telerik:radajaxmanager runat="server" id="radAjax" defaultloadingpanelid="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="grdPendingOrders">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="grdPendingOrders" />
                        <telerik:AjaxUpdatedControl ControlID="grdShippedOrders" />
                        <telerik:AjaxUpdatedControl ControlID="msg" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="grdShippedOrders">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="grdShippedOrders" />
                        <telerik:AjaxUpdatedControl ControlID="msg" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="UseDragColumnCheckBox">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="grdPendingOrders" />
                        <telerik:AjaxUpdatedControl ControlID="grdShippedOrders" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:radajaxmanager>
        <telerik:radscriptblock runat="server" id="scriptBlock">
            <script type="text/javascript">
                <!--
                function onRowDropping(sender, args) {
                    if (sender.get_id() == "<%=grdPendingOrders.ClientID %>") {
                        var node = args.get_destinationHtmlElement();
                        if (!isChildOf('<%=grdShippedOrders.ClientID %>', node) && !isChildOf('<%=grdPendingOrders.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 order?"))
                                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>
        <asp:CheckBox ID="UseDragColumnCheckBox" runat="server" OnCheckedChanged="UseDragColumnCheckBox_CheckedChanged"
            AutoPostBack="true" Text="Use GridDragDropColumn" />
        <telerik:radgrid runat="server" id="grdPendingOrders" onneeddatasource="grdPendingOrders_NeedDataSource"
            allowpaging="True" width="100%" onrowdrop="grdPendingOrders_RowDrop" allowmultirowselection="True"
            pagesize="30" enableheadercontextmenu="True" allowfilteringbycolumn="True" cellspacing="0"
            gridlines="None">
            <MasterTableView DataKeyNames="OrderId" TableLayout="Fixed" AllowFilteringByColumn="true">
                <Columns>
                    <telerik:GridDragDropColumn HeaderStyle-Width="18px" Visible="false" />
                </Columns>
            </MasterTableView>
            <ClientSettings AllowRowsDragDrop="True" AllowColumnsReorder="true" ReorderColumnsOnClient="true">
                <Resizing AllowColumnResize="true" />
                <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
                <ClientEvents OnRowDropping="onRowDropping" />
                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
            </ClientSettings>
            <PagerStyle Mode="NumericPages" PageButtonCount="4" />
        </telerik:radgrid>
    </div>
    <telerik:radgrid runat="server" allowpaging="True" id="grdShippedOrders" onneeddatasource="grdShippedOrders_NeedDataSource"
        width="100%" onrowdrop="grdShippedOrders_RowDrop" allowmultirowselection="true"
        allowfilteringbycolumn="true">
        <MasterTableView DataKeyNames="OrderId" Width="100%" AllowFilteringByColumn="true">
            <Columns>
                <telerik:GridDragDropColumn HeaderStyle-Width="18px" Visible="false" />
            </Columns>
            <NoRecordsTemplate>
                <div style="height: 30px; cursor: pointer;">
                    No items to view</div>
            </NoRecordsTemplate>
            <PagerStyle Mode="NumericPages" PageButtonCount="4" />
        </MasterTableView>
        <ClientSettings AllowRowsDragDrop="True">
            <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />
            <ClientEvents OnRowDropping="onRowDropping" />
        </ClientSettings>
    </telerik:radgrid>
    <a id="trashCan" href="#" onclick="return false;">Recycle Bin</a>
    <div class="exMessage" runat="server" id="msg" visible="false" enableviewstate="false">
        Order(s) successfully deleted!
    </div>
    </form>
</body>
</html>
