473,326 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

145 100+
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 2452
Frinavale
9,735 Expert Mod 8TB
Are you using Ajax (UpdatePanel's) or are you doing full page postbacks to the server?
Sep 16 '09 #2
dorandoran
145 100+
No ajax. I guess full page postback
Sep 16 '09 #3
dorandoran
145 100+
I am trying to follow this but not working.
http://www.codeproject.com/Messages/...lapse-all.aspx
Sep 16 '09 #4
Frinavale
9,735 Expert Mod 8TB
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 100+
sound good and easy. but no exposure to window onload event. let me google.
Sep 16 '09 #6
dorandoran
145 100+
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 Expert Mod 8TB
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
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...
8
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...
1
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? ...
0
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...
5
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...
3
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...
1
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...
2
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...
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.