473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Dropdown cell in table

In my table (ASP.NET 2) that is dynamically generated I have a cell that
initially will only display N rows of text and hide the rest. (This is so
that the rows have a small height and I can display more rows on a page.)
When the user clicks on the cell (or maybe hovers the mouse over it) then I
want the cell to expand to display all of the rows.

Can someone help me out as to how I implement it? I've been told to use
expanding DIVs but I haven't managed to find any useful examples online. Any
client scripting would be in JavaScript.
Jun 27 '08 #1
3 1611
Try something like the following (you will obviously want different
height/width values):

<span style="display:block;height:100px;width:300px;over flow:hidden;"
onmouseover="this.style.height='auto';"
onmouseout="this.style.height='100px';"></span>

If you have specified any CSS for your table, it is possible that you may
need the onmouseover/onmouseout to modify them as well. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"chris f" <ch**********@nospam.co.ukwrote in message
news:eQ**************@TK2MSFTNGP03.phx.gbl...
In my table (ASP.NET 2) that is dynamically generated I have a cell that
initially will only display N rows of text and hide the rest. (This is so
that the rows have a small height and I can display more rows on a page.)
When the user clicks on the cell (or maybe hovers the mouse over it) then
I want the cell to expand to display all of the rows.

Can someone help me out as to how I implement it? I've been told to use
expanding DIVs but I haven't managed to find any useful examples online.
Any client scripting would be in JavaScript.

Jun 27 '08 #2
Thanks. Is there a way to set the initial span height dynamically because at
the time that the span is created then my web app doesn't know the text
height being used?

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Try something like the following (you will obviously want different
height/width values):

<span style="display:block;height:100px;width:300px;over flow:hidden;"
onmouseover="this.style.height='auto';"
onmouseout="this.style.height='100px';"></span>

If you have specified any CSS for your table, it is possible that you may
need the onmouseover/onmouseout to modify them as well. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"chris f" <ch**********@nospam.co.ukwrote in message
news:eQ**************@TK2MSFTNGP03.phx.gbl...
>In my table (ASP.NET 2) that is dynamically generated I have a cell that
initially will only display N rows of text and hide the rest. (This is so
that the rows have a small height and I can display more rows on a page.)
When the user clicks on the cell (or maybe hovers the mouse over it) then
I want the cell to expand to display all of the rows.

Can someone help me out as to how I implement it? I've been told to use
expanding DIVs but I haven't managed to find any useful examples online.
Any client scripting would be in JavaScript.


Jun 27 '08 #3
Yes, just do it the same way you would set any attribute dynamically. Here
are several methods I am working that you may be interested in that will
soon be on my website (they are written using VB.NET 2.0, but they could
easily be modified if you need to convert them to C#):

Public Class Rollovers
Public Shared Sub AddRolloverExpansionHeight(ByVal ctrl As
System.Web.UI.WebControls.WebControl, ByVal initialheight As String, ByVal
expandedheight As String)
If ctrl.Style.Value = Nothing Then
ctrl.Style.Value =
String.Format("display:block;overflow:hidden;heigh t:{0};", initialheight)
Else
If Not ctrl.Style.Value.Contains("display:block") Then ctrl.Style.Value =
"display:block;" & ctrl.Style.Value
If Not ctrl.Style.Value.Contains("overflow:hidden") Then ctrl.Style.Value
= "overflow:hidden;" & ctrl.Style.Value
ctrl.Style.Value &= String.Format("height:{0};", initialheight)
End If
ctrl.Attributes.Add("onmouseover",
String.Format("this.style.height='{0}';", expandedheight))
ctrl.Attributes.Add("onmouseout",
String.Format("this.style.height='{0}';", initialheight))
End Sub

Public Shared Sub AddRolloverExpansionHeight(ByVal ctrl As
System.Web.UI.WebControls.WebControl, ByVal initialheight As String)
AddRolloverExpansionHeight(ctrl, initialheight, "auto")
End Sub

Public Shared Sub AddRolloverExpansionWidth(ByVal ctrl As
System.Web.UI.WebControls.WebControl, ByVal initialwidth As String, ByVal
expandedwidth As String)
If ctrl.Style.Value = Nothing Then
ctrl.Style.Value =
String.Format("display:block;overflow:hidden;width :{0};", initialwidth)
Else
If Not ctrl.Style.Value.Contains("display:block") Then ctrl.Style.Value =
"display:block;" & ctrl.Style.Value
If Not ctrl.Style.Value.Contains("overflow:hidden") Then ctrl.Style.Value
= "overflow:hidden;" & ctrl.Style.Value
ctrl.Style.Value &= String.Format("width:{0};", initialwidth)
End If
ctrl.Attributes.Add("onmouseover",
String.Format("this.style.width='{0}';", expandedwidth))
ctrl.Attributes.Add("onmouseout", String.Format("this.style.width='{0}';",
initialwidth))
End Sub

Public Shared Sub AddRolloverExpansionWidth(ByVal ctrl As
System.Web.UI.WebControls.WebControl, ByVal initialwidth As String)
AddRolloverExpansionWidth(ctrl, initialwidth, "auto")
End Sub

Public Shared Sub AddRolloverExpansion(ByVal ctrl As
System.Web.UI.WebControls.WebControl, ByVal initialheight As String, ByVal
initialwidth As String, ByVal expandedheight As String, ByVal expandedwidth
As String)
If ctrl.Style.Value = Nothing Then
ctrl.Style.Value =
String.Format("display:block;overflow:hidden;heigh t:{0};width:{1};",
initialheight, initialwidth)
Else
If Not ctrl.Style.Value.Contains("display:block") Then ctrl.Style.Value =
"display:block;" & ctrl.Style.Value
If Not ctrl.Style.Value.Contains("overflow:hidden") Then ctrl.Style.Value
= "overflow:hidden;" & ctrl.Style.Value
ctrl.Style.Value &= String.Format("height:{0};width:{1};", initialheight,
initialwidth)
End If
ctrl.Attributes.Add("onmouseover",
String.Format("this.style.height='{0}';this.style. width='{1}';",
expandedheight, expandedwidth))
ctrl.Attributes.Add("onmouseout",
String.Format("this.style.height='{0}';this.style. width='{1}';",
initialheight, initialwidth))
End Sub

Public Shared Sub AddRolloverExpansion(ByVal ctrl As
System.Web.UI.WebControls.WebControl, ByVal initialheight As String, ByVal
initialwidth As String)
AddRolloverExpansion(ctrl, initialheight, initialwidth, "auto", "auto")
End Sub
End Class
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"chris f" <ch**********@nospam.co.ukwrote in message
news:eb**************@TK2MSFTNGP03.phx.gbl...
Thanks. Is there a way to set the initial span height dynamically because
at the time that the span is created then my web app doesn't know the text
height being used?

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>Try something like the following (you will obviously want different
height/width values):

<span style="display:block;height:100px;width:300px;over flow:hidden;"
onmouseover="this.style.height='auto';"
onmouseout="this.style.height='100px';"></span>

If you have specified any CSS for your table, it is possible that you may
need the onmouseover/onmouseout to modify them as well. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"chris f" <ch**********@nospam.co.ukwrote in message
news:eQ**************@TK2MSFTNGP03.phx.gbl...
>>In my table (ASP.NET 2) that is dynamically generated I have a cell that
initially will only display N rows of text and hide the rest. (This is
so that the rows have a small height and I can display more rows on a
page.) When the user clicks on the cell (or maybe hovers the mouse over
it) then I want the cell to expand to display all of the rows.

Can someone help me out as to how I implement it? I've been told to use
expanding DIVs but I haven't managed to find any useful examples online.
Any client scripting would be in JavaScript.



Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joe Smith | last post by:
Hi, I'm using the code below to change the contents of a cell table in IE. The problem is that the cell size won't adjust to the size of the content, as its positions have been declared 'absolute'....
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
7
by: jeff | last post by:
Doing this: td{border: 1px solid black} gives me 2px borders on adjacent cells. How do I get the same size border on inside cell walls as outside, much as <table border="1" cellspacing="0">...
3
by: Sandy Bremmer | last post by:
I was curious how one goes about properly creates a table row with multiple TD cells as a single hyperlink because I have seen examples of what I think is invalid and poorly conceived HTML. It...
2
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box...
4
by: [Jongware] | last post by:
I'm a bit stumped about this request on an Adobe forum. Apparently, exporting a table from their flagship InDesign to XML produces the following output for a table (only first 2 rows listed; after...
10
by: gater | last post by:
Hello All. I am trying to set up a page that will display the 'picture of month' for each month of a given year. I want 3 columns of thumbs. There may be no images or up to 12 images for any given ...
1
by: abhishekbrave | last post by:
I hava xml code in following format. My aim is to convert this show the data present here in tabular format to a HTML page. <table bid="18" sid="7" ref="REF_17" x="0" y="80" h="50" w="607"...
3
by: filippo nanni | last post by:
Hello, I have a series of xml tables that i should convert to html code - Here is an Example: <TABELLA data_mod="2008-10-30 12:20:59" id="2903" locale="it_IT" colonne="1" righe="2" ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.