I have got my script working to restrict only one dock in a zone.
But the problem I am having is, it works only if I drag the dock below the current dock. Say there are two zones:
Zone Destination
---------------------------
Dock A
Zone Origin
---------------------------
Dock B
I am moving Dock B to Zone Destination, when it is dropped, the script will check if Zone Destination has more than 1 dock, if so, remove old dock and replace with new dock. Old dock will get sent back to Zone Origin.
It works fine, but only if I drag Dock B below Dock A. If I drag Dock B above Dock A, it will just append to the zone.
What am I missing here?
Here's the script:
For dock B:
But the problem I am having is, it works only if I drag the dock below the current dock. Say there are two zones:
Zone Destination
---------------------------
Dock A
Zone Origin
---------------------------
Dock B
I am moving Dock B to Zone Destination, when it is dropped, the script will check if Zone Destination has more than 1 dock, if so, remove old dock and replace with new dock. Old dock will get sent back to Zone Origin.
It works fine, but only if I drag Dock B below Dock A. If I drag Dock B above Dock A, it will just append to the zone.
What am I missing here?
Here's the script:
<script type="text/javascript"> |
function SetHandleDock(dock, args) { |
dock.set_handle(document.getElementById(dock.get_id())); |
} |
var dockZoneID; |
function checkMaximumDock(dock) { |
var selectionZone = $find('<%= radDockZone.ClientID %>'); |
var newDockZoneID = dock.get_dockZoneID(); |
//if the dock is floated or dropped in the selection zone return |
if (newDockZoneID == '' || selectionZone.get_clientID() == newDockZoneID) return; |
if (dockZoneID != newDockZoneID) { |
var dockZone = $find(newDockZoneID); |
var docks = dockZone.get_docks(); |
if (docks.length > 1) { |
var oldDock = docks[0]; |
oldDock.undock(); |
selectionZone.dock(oldDock); |
dockZone.dock(dock); |
} |
} |
} |
function OnClientDragStart(dock) { |
dockZoneID = dock.get_dockZoneID(); |
} |
</script> |
For dock B:
radDock.OnClientDragEnd = "checkMaximumDock"; |
radDock.OnClientDragStart = "OnClientDragStart"; |