Solved

Resize tr when inner div is hidden

Posted on 2014-02-11
5
277 Views
Last Modified: 2014-02-11
Hi Experts,

I have a gridview inside a <div> inside a <tr> tag. I want the gridview to be hidden or displayed on mouseover, but I want the row to expand and contract as needed.

Currently, I have the following html and js, but it's not working. Can you help?

<tr id="trStatus">
                            <td class="auto-style3">Status</td>
                            <td class="auto-style3">
                                <div onmouseover="showStatusDetails()" onmouseout="hideStatusDetails()"><u><asp:Label ID="lbStatus" runat="server" Text="Status"></asp:Label></u></div>
                                <div id="divStatusDetails">
                                    <asp:GridView ID="gvStatus" runat="server" DataSourceID="sqlDSoStatus" GridLines="Horizontal">
                                         <Columns>
                                            <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
                                           </Columns>
                                    </asp:GridView>
                                </div>
</td></tr>
                            <script type="text/javascript">
                                
                                var divDetails = document.getElementById("divStatusDetails");

                                function hideStatusDetails() {

                                    divDetails.style.visibility = "hidden";
                                    trStatus.style.height = "30px";
                                }
                                

                                function showStatusDetails() {

                                    divDetails.style.visibility = "visible";
                                    trStatus.clientHeight == tdStatus.clientHeight + divDetails.clientHeight;
                                }


                                window.onload = hideStatusDetails();
                         </script>

Open in new window


Thanks, Thomas
0
Comment
Question by:nutsch
  • 3
5 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39851250
Change .visibility to .display then use none/block to hide/show

e.g.
divDetails.style.display= "none";

Using visibility just hides the object but maintains the space used. Using display removes it from the page
0
 
LVL 2

Expert Comment

by:DualCool
ID: 39851251
can you show your css and full table code?
0
 
LVL 2

Expert Comment

by:DualCool
ID: 39851254
on first glance it looks like your div that has the mouseover/out events needs a height/width
0
 
LVL 2

Expert Comment

by:DualCool
ID: 39851278
also declare trStatus in your javascript

var trStatus = document.getElementById("trStatus");
0
 
LVL 39

Author Closing Comment

by:nutsch
ID: 39851298
Thanks all. The .display solution worked perfectly for my needs.

Thomas
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now