I developed my own Web-Admin behind the front-end. It's a typical Admin with container , one menu-navigation in the left and a body content in the right which shows the result (typically a table) related to the clicked menu item.
What is the best way to get the correct number or rows in the table in order to fit the the body page at 100% ?
In my case, i have seen that the number of tow required to fill the space in the table is different while changing the screen resolution.
I know a quick solution could be to calculate the resolution and get the table populated after knowing the screen resolution. I was wondering if if possible to set the TD or TR height at runtime, based on the screen resolution or somehow else.
Thanks,
Change column and row height To make all rows in the table the same height, select Layout > Distribute Rows. To make all the columns in the table the same height, select Layout > Distribute Columns. Note: In Excel, select Home > Format, and then select Row Height.
Resize rows, columns, or cells Select the table. The contextual tabs, Table Design and Layout, appear in the ribbon. On the Layout tab, you can specify the custom height and width. To resize specific rows or column, click on a cell and then adjust the row/column.
To manipulate the height or width of an entire table, place the size attribute (either "WIDTH=" or "HEIGHT=") within the <TABLE> code. To manipulate individual cells, place the size attribute within the code for that cell.
To set the cell width and height, use the CSS style. The height and width attribute of the <td> cell isn't supported in HTML5. Use the CSS property width and height to set the width and height of the cell respectively. Just keep in mind, the usage of style attribute overrides any style set globally.
Here is a fiddle that demonstrates the rendering of rows depending on the browser innerHeight.
HTML
<table id="mytable"></table>
CSS
td {
height:20px;
}
JavaScript
var numberOfRows = Math.floor(window.innerHeight / 20);
var table = document.getElementById("mytable");
function createCell() {
var cell = document.createElement("td");
cell.innerText = "Cell";
return cell;
}
function createRow() {
var row = document.createElement("tr");
row.appendChild(createCell())
return row;
}
for (var i = 0; i < numberOfRows; i++) {
table.appendChild(createRow());
}
PS. 1 I've set the height of the cell in CSS, this can be done differently
PS. 2 I've floored the number of rows that fit on the screen. So there will be some empty space at the bottom.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With