2014年7月13日 星期日

[RESOLVED] Changing the height of a GridView


Hello everyone,


I have a div that loads 2 different GridViews based on a search. The search can result in multiple details for GridView1 and GridView2.


The first record of GridView1 should line up with the first record of GridView2 and so on...


Here is the code I am using 



SOME HEADER









...











...







Currently I am using Height="480" but for many of the gridview items there is empty space after them


I am looking for a way to change the Height of all gridviews based on the gridview with the greatest height.


Is what I'm trying to do even possible?



Try give 100% for GridView Height only, remove any itemstyle height etc..









I have tried that. When I use that option the only the first record from GridView1 lines up with the first record of GridView2. If there are more records they do not line up becuase of the varying sizes of the GridView.


I've also tried creating a Table and adding each record to the TableCell but that doesn't work either.


I've tried creating a

I'm still going through several test though to make sure I don't run into any errors



Ok, the

Regardless of which Table#.length I use they will be the same length. So it doesn't matter which one I use in the loop.


If you are wondering why I add 10 to the Height in the "If Statement", if I don't all the tables will be off by a few pixels. I'm not sure what causes it I just know increasing the Height by 10 fixes that problem. Also, it looks a lot nicer having that clean
break in it. And I need to add 10 to both GridViews to keep them the same height.


Each childNodes[i] is a row that contains another Table, in some cases 2 more tables. The childNodes[i] from each gridview need to be the same height, regardless of how many tables may be in that row.


Thank you everone for you help and support!


Abe



I know you have found your answer but this also worked for me using jquery...



boxes = $('table[name="table-main"]');
maxHeight = Math.max.apply(
Math, boxes.map(function () {
return $(this).height();
}).get());
boxes.height(maxHeight);

//could also be done as

boxes = $('.someclass');
maxHeight = Math.max.apply(
Math, boxes.map(function () {
return $(this).height();
}).get());
boxes.height(maxHeight);







document.getElementById("GridView1").height=document.getElementById("GridView2").height;


沒有留言:

張貼留言