Solved

Resize tr when inner div is hidden

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

776 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