Solved

hide and display div in nested gridview

Posted on 2009-03-30
1
1,591 Views
Last Modified: 2013-11-07
I've used a javascript item from another posted question, but am finding it difficult to adapt it for a page with multiple mastergrids each containing nested gridviews. Hope that makes sense.

I have 7 mastergrids, each with a unique names. The problem I have is that the doc_id could appear in any number of mastergrids.  When clicking on the link to show the div it makes visible the first on it finds, even if it is not in the mastergrid you are currently viewing. I need it to open the div in the mastergrid/nested gridview that I m clicking.

Hope someone can point me in the right direction. I'm too tired now for looking ;-)
The JavaScript
 
<script type="text/javascript">
function ShowChildGrid(obj)
{
    var div = document.getElementById(obj);
    var img = document.getElementById('img' + obj);
    var theFlag = div.style.display == "none";
    div.style.display = (theFlag) ? "inline" : "none";
    img.src = (theFlag) ? "images/buttons/tl_arrow_down.gif" : "images/buttons/tl_arrow_straight.gif";
}
</script>
 
The button call
 
<a href="javascript:ShowChildGrid('div<%# Eval("doc_id") %>');">
                    <img id="imgdiv<%# Eval("doc_id") %>" 
                        alt="Click to show/hide documents" 
                        border="0" src="images/buttons/tl_arrow_straight.gif" />
                </a>
 
The div
 
<div id="div<%# Eval("doc_id") %>" style="display:none;position:relative;" >

Open in new window

0
Comment
Question by:craigywoos
[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
1 Comment
 

Accepted Solution

by:
craigywoos earned 0 total points
ID: 24020246
Oh, it was so obvious. Of course it wasn't going to work.

I just needed to add a unique div id for each mastergrid.

So for this sample I've added MOD to uniquely identify this mastergrid. Just replace this for each mastergrid with something else.
Button call
 
<a href="javascript:ShowChildGrid('divMOD<%# Eval("doc_id") %>');">
                    <img id="imgdivMOD<%# Eval("doc_id") %>" 
                        alt="Click to show/hide documents" 
                        border="0" src="images/buttons/tl_arrow_straight.gif" />
                </a>
 
 
The div
 
<div id="divMOD<%# Eval("doc_id") %>" style="display:none;position:relative;" >

Open in new window

0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Introduction ( All good things must come to an end ) The original MySQL API has gone away.  It was deprecated (years ago) by PHP in Version 5.5, and removed from PHP in all current releases .  As a result, the issue is upon us today.  It's time to …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

717 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