?
Solved

Resize tr when inner div is hidden

Posted on 2014-02-11
5
Medium Priority
?
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

765 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