Solved

Resize tr when inner div is hidden

Posted on 2014-02-11
5
283 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

943 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

1 Experts available now in Live!

Get 1:1 Help Now