Get DockingOrder

This post has 5 replies

Not Ranked
Posts: 4
niket Posted: Tue May 17, 2005 @ 1:33 AM
Hi,

I have 5 snaps in a single container. They are arranged from top to bottom. Now I will be saving this information(which snaps are where and which order) in a database to load it from there and create snaps dynamically the second time round.

How can i find out what is the order of the snaps. Means which position is Snap1 in i.e is it at the top or 2nd ,etc.

Regards
NIKET
Top 25 Contributor
Posts: 431
KirkFuller Posted: Tue May 17, 2005 @ 5:21 AM
I have just done this exact same thing. You must use a combination of server and client side items. In my instance the snaps are loaded dynamically from the db at runtime in their current order. Upon calling a function I capture the new order and update it in the db. First you must make sure that each of your snaps have a separate ID. I am using the following code.. While objReader.Read 'set id string objSnapID = "SP_" & CType(objReader("SPindex"), String).Trim objSnap = New ComponentArt.Web.UI.Snap objSnap.DockingStyle = ComponentArt.Web.UI.SnapDockingStyleType.TransparentRectangle objSnap.DraggingStyle = ComponentArt.Web.UI.SnapDraggingStyleType.Original objSnap.MustBeDocked = True objSnap.ID = objSnapID objSnap.DockingContainers = "LeftColumn" objSnap.CurrentDockingContainer = "LeftColumn" objSnap.CssClass = "SnapMain" 'header info objSnapHeader = New SnapHeader objSnapHeader.Title = CType(objReader("Title"), String).Trim objSnapHeader.SnapID = objSnapID objSnap.HeaderTemplate = objSnapHeader 'closed header info objSnapHeaderClosed = New SnapHeaderClosed objSnapHeaderClosed.Title = CType(objReader("Title"), String).Trim objSnapHeaderClosed.SnapID = objSnapID objSnap.CollapsedHeaderTemplate = objSnapHeaderClosed 'dynamically add content to template objSnap.ContentTemplate = Page.LoadTemplate("SafetyPillarSnap.ascx") 'add snap control to page PlaceHolder1.Controls.Add(objSnap) 'set value of label in content template objLabel = CType(objSnap.FindControl("PillarDescript"), Label) objLabel.Text = CType(objReader("Description"), String).Trim End While The objSnapID string value is created for each snap using a combination of "SP_" + a unique identifier from the db. This will be used on the client side to create a comma separated value of the snap order. You will also need 2 functions on the client side. I perfer to use a client side button, call my client side code, then reference a server button (w/ display=none) and call its click cmd to initiate a server side click event. Here are my 2 functions... function HTMLClick() { //call fct to get order and fill a hidden field w/ comma separated order values ListOrder(); //get reference to hidden (disply:none) server side button var objSvrBtn=document.getElementById('btnCheckOrder'); objSvrBtn.click(); } function ListOrder() { //iterate through all controls in left column to create comma separated order list //reference the controls (snaps) found in the dock //(LeftColumn is the only dock beind used) var snapCtrls=LeftColumn.children; //reference the hidden field & clear its value var objLtl=document.getElementById('saveVal'); objLtl.value=''; //loop through all controls (snaps) found in the dock //appending their unique identifer to the hidden field for(var i=0;iThe hidden input field is a standard HTML hidden input w/ runat = server and a reference too it on the code behind page. Finally you will need to retrieve this value, store it in an array, then use this to create your SQL update strings. The following code resides in the server click event for the server side button control ID='btnCheckOrder' 'retrieve snap order into array spOrder = Split(CType(saveVal.Value, String).Substring(0, saveVal.Value.Length - 1), ",") 'set item count iCount = 0 'create db update string While iCount < spOrder.Length 'create order (when iCount=0 iOrder=1) iOrder = iCount + 1 sqlStr.Append("UPDATE myTable SET LoadOrder=" & iOrder & " WHERE SPindex=" & spOrder.GetValue(iCount) & ";") iCount += 1 End While I know this is a lot so please let me know if I need to clarify somewhere. -Kirk
Top 25 Contributor
Posts: 431
KirkFuller Posted: Thu May 19, 2005 @ 9:00 AM
Found one issue with my code. When I loaded the page from within an iFrame the PlaceHolder control did not always allow the snaps to properly load in order to the dock. In this case I used
Page.Controls.Add(objSnap)

The only downside to this is that you can see each snap load to the dock where as with the placeholder they all appeared at once. Minor for my application though.

-Kirk
Top 25 Contributor
Posts: 228
cjaskoll Posted: Thu Apr 27, 2006 @ 11:58 AM
thanks for the code, kirk.

however, i have found that click on the client-hidde-button to initiative server-side code is not reliable.

any ideas?
Top 25 Contributor
Posts: 431
KirkFuller Posted: Fri Apr 28, 2006 @ 12:05 PM
I've not had any issues with this but then again, I'm spoiled writing internal apps where IE is the only browser allowed on the network.

You could add the onclick event to your server-side button at page load.
btnCheckOrder.Attributes.Add("onclick","javascript:ListOrder();")
I use this method for delete buttons in my grid to confirm if the user wants to delete a given row. Return true and the serverside fires, false and nothing happens.

Hope this helps!
-Kirk
Not Ranked
Posts: 1
mail.josephj Posted: Thu Jul 7, 2011 @ 11:01 PM
This code isn't working for me. I have two placeholders and in that two groups of snaps, I want to save the Dock state to the database whenever a snap dock event is fired. after reading this information I tried to implement in my code. but was not successul.
Please could you share the real sample code.

Thanks in advance.
-Joseph J
Page 1 of 1 (6 items)