Dynamic Snap creation on server

Answered (Verified) This post has 1 verified answer and 2 replies

Top 75 Contributor
Posts: 66
JimiJ Posted: Fri May 14, 2010 @ 10:05 AM

I want to create a dynamic list of Snap controls from the server.  I have 1 outer snap defined in the script page and I want to add N Snap controls inside of it based on input data.  How do I do positioning for this?  Right now I am adding 2 of them and they are overlapping.  I create a Snap control on the server and assign the headers and content with dynamic HTML. Then I assign that to the controls collection of the containing outside Snap.  Any suggestions for placement?  I want the dynamically created Snaps to flow like a document but they are not.. Also the footer is not being shown.

Jim

Answered (Verified) Verified Answer

Top 75 Contributor
Posts: 66
Answered (Verified) JimiJ Posted: Mon May 17, 2010 @ 8:05 AM
Verified by stephen
Hello,
Nevermind I fixed the issue.  Forgive me.. I am a newbie! I needed a docking panel ID and I created a <TD> in my table with an ID to dock to.

Thanks for looking though!
Jim

All Replies

Top 75 Contributor
Posts: 66
JimiJ Posted: Fri May 14, 2010 @ 2:52 PM
Hello.  All my Snap content overlaps.  Here is my crude implementation:

 

for (int h = 0; h < dt.Rows.Count - 1; h++)

{

 

if (h != 0)

h = current + 1;

 

if (h >= dt.Rows.Count - 1)

 

break;

iCurrentGroupId =

int.Parse(dt.Rows[h]["groupId"].ToString());

 

 

Snap newSnap = new Snap();

newSnap.ID =

"Snap" + h.ToString();

 

SnapContent snapHeader = new SnapContent();

 

Literal snapHeaderText = new Literal();

snapHeaderText.Text =

@"<br/><br/><br/><div style='CURSOR: move; width: 100%;'><table cellspacing='0' cellpadding='0' width='100%' border='0' style='background-color:Aqua; font-family:Arial Narrow'><tr><td width='10' style='cursor: hand' align='right'>" + dt.Rows[h]["groupDescription"].ToString() + @"<img onclick='" + newSnap.ID.ToString() + @".toggleExpand();' src='ImageFolder/minus.gif' width='15' height='15' border='0'></td></tr></table></div>";

snapHeader.Controls.Add(snapHeaderText);

 

SnapContent snapHeaderCollapsed = new SnapContent();

 

Literal snapHeaderCollapsedText = new Literal();

snapHeaderCollapsedText.Text =

@"<br/><br/><br/><div style='CURSOR: move; width: 100%;'>

<table cellspacing='0' cellpadding='0' width='100%' border='0' style='background-color:Aqua; font-family:Arial Narrow'>

<tr>

<td width='30' style='cursor: hand' align='right'>"

 

+ dt.Rows[h]["groupDescription"].ToString() +

 

@"<img onclick='" + newSnap.ID.ToString() + @".toggleExpand();' src='ImageFolder/plus.gif' width='15' height='15' border='0'></td>

</tr></table></div>"

 

;

snapHeaderCollapsed.Controls.Add(snapHeaderCollapsedText);

newSnap.Header = snapHeader;

newSnap.CollapsedHeader = snapHeaderCollapsed;

 

Literal snapContentText = new Literal();

 

SnapContent snapContent = new SnapContent();

 

 

for (int g = h; g <= dt.Rows.Count - 1; g++)

{

 

if ((iCurrentGroupId == int.Parse(dt.Rows[g]["groupId"].ToString())))

{

 

double dpercent = (double.Parse(dt.Rows[g]["totalAmount"].ToString()) / dTotal) * 100;

 

int ipercent = (int)dpercent;

 

int ipercentleft = 100 - ipercent;

snapContentText.Text +=

@"<table width='100%' style='font-family:Arial Narrow'>

<tr><td style='width:40%'>"

 

+ dt.Rows[g]["familyDescription"].ToString() + @"</td>

<td style='width:50%'>

<table style='width:100%'><tr style='width:100%'>

<td style='style=background-image:url('/ImageFolder/percentage_bar_small.JPG');background-repeat:repeat-x;width:"

 

+ ipercent.ToString() + @"%'></td>

<td style='width:"

 

+ ipercentleft.ToString() + @"%'>&nbsp;</td>

</tr>

</table>

<td style='width:10%;'>"

 

+ String.Format("{0:0.00}", dpercent) + @"%</td>

 

</tr></table>"

 

;

}

 

else

{

current = g;

 

break;

}

 

}

 

snapContent.Controls.Add(snapContentText);

newSnap.Content = snapContent;

 

//Snap1.Content = newSnap.Content;

Snap1.Content.Controls.Add(newSnap);

 

}

 

 


 

SnapContent snapFooter = new SnapContent();

 

Literal snapFooterText = new Literal();

snapFooterText.Text =

@"<table width='100%' style='font-family:Arial Narrow'>

<tr><td style='width:40%'>Total:</td>

<td style='width:50%'>&nbsp;</td><td style='width:10%;background-color:Aqua;'>100%</td>

</tr></table>"

 

;

snapFooter.Controls.Add(snapFooterText);

Snap1.Footer = snapFooter;

}

Do I need docking containers? Also why does the footer not display?
Thanks in advance,
Jim

Top 75 Contributor
Posts: 66
Answered (Verified) JimiJ Posted: Mon May 17, 2010 @ 8:05 AM
Verified by stephen
Hello,
Nevermind I fixed the issue.  Forgive me.. I am a newbie! I needed a docking panel ID and I created a <TD> in my table with an ID to dock to.

Thanks for looking though!
Jim
Page 1 of 1 (3 items)