Hi,
I have two question about settings the height of the rows in an ejGrid control.
1. Set a different height for the first n rows only
I'm trying to find a way to set the height of the first n rows, which are frozen rows, to look smaller than the other.
If I apply a CSS rule like the following (n=2):
#grids-container .ra-typ tbody tr:nth-child(-n+2) td{height: 32px !important;}
#grids-container .ra-bad tbody tr:nth-child(-n+2) td{height: 32px !important;}
Everything is broken and the grids don't load anymore.
So, how can I set a different height to the first two, or three, or four rows without broken the grid controls?
2. Setting the height of the rows programmatically, after the control has already loaded.
As you can see from the playground I have two grids side by side, the rows in them are strictly related to each other, so they must be of the same height to keep the alignment.
But if a cell in the right grid has a lot of content, the row get higher than its counterpart on the left grid, losing the alignment.
(you can see this behaviour in the last two rows of the grids in the playground, for the event named "Preferred transfer modality")
My idea was to make a loop for each td.e-rowcell element inside the .e-movablecontent to retrieve the height value of the highest cell.
Then looping on the grids, excluding the frozen rows that will have their own height, I set the same height to all cells. Here is the code:
var maxHeight=0;
//Loop through the left grid...
$.each($('#grids-container .ra-typ .e-movablecontentdiv tbody tr.e-row td.e-rowcell'),function(i,val){
if(maxHeight<$(this).height()){
maxHeight=$(this).height();
}
});
//Loop through the right grid...
$.each($('#grids-container .ra-bad .e-movablecontentdiv tbody tr.e-row td.e-rowcell'),function(i,val){
if(maxHeight<$(this).height()){
maxHeight=$(this).height();
}
});
//set the height to all the cells...
$.each($('#grids-container .ra-typ tbody tr.e-row td.e-rowcell'),function(i,val){
$(this).css('line-height', maxHeight + 'px !important'); //nothing happens!
$(this).css('height',maxHeight + 'px !important'); //nothing happens!
$(this).height(maxHeight); //nothing happens!
});
But with the above code nothing happens.
So, how can I set the height of the td.e-rowcell elements using javascript?
Many thanks for the support,
Best Regards,
Marco