473,626 Members | 3,191 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto expand the grid upon search... - HIGH PRIORITY

145 New Member
I used this article (http://www.codeproject.com/KB/webfor...dGridView.aspx) to accomplish expand/collaspe grid. I also added a search and it works. but i need to be now automatically expand the corresponded grid where search was found.

User has to click on all the parent grid to find out which child grid has records. How can I automatically expand the grid where there are results?

I probably need a function like below ExpandAll() which i can call right after I call this method fillsubgrid() upon clicking the search button. the following i m using for expand/collaspe.

Expand|Select|Wrap|Line Numbers
  1. function expandcollapse(obj,row)
  2.     {
  3.         var div = document.getElementById(obj);
  4.         var img = document.getElementById('img' + obj);
  5.  
  6.  
  7.  
  8.         if (div.style.display == "none")
  9.         {
  10.             div.style.display = "block";
  11.             if (row == 'alt')
  12.             {
  13.                 img.src = "minus.gif";
  14.             }
  15.             else
  16.             {
  17.                 img.src = "minus.gif";
  18.             }
  19.             img.alt = "Close to view other Records";
  20.         }
  21.         else
  22.         {
  23.             div.style.display = "none";
  24.             if (row == 'alt')
  25.             {
  26.                 img.src = "plus.gif";
  27.             }
  28.             else
  29.             {
  30.                 img.src = "plus.gif";
  31.             }
  32.             img.alt = "Expand to show Records";
  33.         }
  34.     }
Sep 16 '09 #1
7 2458
Frinavale
9,735 Recognized Expert Moderator Expert
Are you using Ajax (UpdatePanel's) or are you doing full page postbacks to the server?
Sep 16 '09 #2
dorandoran
145 New Member
No ajax. I guess full page postback
Sep 16 '09 #3
dorandoran
145 New Member
I am trying to follow this but not working.
http://www.codeproject.com/Messages/...lapse-all.aspx
Sep 16 '09 #4
Frinavale
9,735 Recognized Expert Moderator Expert
You should look into using the window.onload event.

Write a function that will handle the window's onload event and expand the grid upon successful search....
Sep 16 '09 #5
dorandoran
145 New Member
sound good and easy. but no exposure to window onload event. let me google.
Sep 16 '09 #6
dorandoran
145 New Member
No luck. I did not find any link that talks about how to expand grids on window. onload. please suggest.
Sep 25 '09 #7
Frinavale
9,735 Recognized Expert Moderator Expert
You need to write a JavaScript function that expands the grids.
Then you need to specify that this JS function should be called during the window.onload event.

For example, say you have the following JavaScript function that expands all of the rows in the grid:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript>
  2. //<![CDATA[ 
  3.   function ExpandAll() {
  4.     var allRowElements = document.getElementsByTagName("tr");
  5.     var numElements = allRowElements .length;
  6.     for (var i = 0; i < numElements; i++) {
  7.       allRowElements [i].style.display = "table-row";
  8.     }
  9.   }
  10.   function CollapseAll() {
  11.     var allRowElements = document.getElementsByTagName("tr");
  12.     var numElements = allRowElements .length;
  13.     for (var i = 0; i < numElements; i++) {
  14.       allRowElements [i].style.display = "none";
  15.     }
  16.   }   
  17. //]]>
  18. </script>
  19.  
You would call that function during the window.onload event like:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. //<![CDATA[
  3.   if(window.attachEvent){
  4.     window.attachEvent("onload",ExpandAll);
  5.   }else{
  6.     window.addEventListener("load",ExpandAll);
  7.   }
  8. //]]>
  9. </script>
Sep 25 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1801
by: Marc | last post by:
Hi all, Perplexed by this. I thought the sticky option was supposed to accomplish this task, but it doesn't seem to be working. Here is what I'm trying to accomplish. Window ---------------------------- | --Beginning of group-- | Cell1 Cell2 Cell3
8
4874
by: 2centbob | last post by:
Has anyone had an issue with SQL Server not being able to expand against a RAID 5 file system? My current configuration is that the server is started and stopped using the local system account. I have only one database (besides the master, model,etc)on the server. What has happend to me several times is that the primary database in question try's to expand the main datafile for the database (.mdf). I setup the database to not expand...
1
2202
by: mike | last post by:
I have a datagrid which includes one table. Setting the expand property to -1 as illustrated below isn't expanding the grid. Should I be doing something else? dgdQuotes.ColumnHeadersVisible=true; dgdQuotes.Expand(-1); //expand all rows dgdQuotes.Refresh();
0
1164
by: CJ | last post by:
I have a Crystal Report displaying nicely via asp.net, plus having it convert to pdf via asp.net - but here's the problem: there're certain sections on the report that're hidden and hence expand when clicked on. These hidden sections don't display within the PDF (and the "click to expand" function is dead also) - how can I make them auto expand when viewed as a PDF? I'm trying using a parameter to switch auto-expand on and off, but you...
5
5037
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the CurrentUICulture to what's specified in the querystring. Since I want to allow UICulture auto detecting, I add UICulture = "auto" to page directive on each page.
3
1280
by: jcouse | last post by:
I am trying to find if a string exists in a file. If it doesn’t, it should return a “-1” and I’ll make my decision based on that Here is a sniplet of the text file game name mapp description "Mappy (US) year 198 manufacturer "Namco history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US manufacture and distribution. (03/1983) \n\n- SERIES: \n\n1. Mappy \n2. Hopping Mappy \n\n0.26 \n\nBugs: \n-...
1
2278
by: libsfan01 | last post by:
hi all! how can you get an iframe to automatically expand vertically to show the entire contents of the page. for example if that page contained content that was shown or displayed onclick how would you get the iframe to expand to show the now visible content and also contract if it was hidden? thanks in advance
2
1670
by: Alec | last post by:
Newbie question. Its really an SQL question, but have had no reply from the SQL newsgroup. I want to search the same table for two different criteria, and then join the search results together into one new list. See below. <?php
0
1010
by: hi | last post by:
The truth about Prophet Muhammad (Peace Be Upon Him) Loving him is following him Muslims all over the world are deeply hurt by the recent caricatures of our beloved Prophet Muhammad , in Danish and several other publications.
0
8268
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8202
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8641
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.