Is it possible to fix <footer> in bootstraptable? - bootstrap-table

i found the showFooter Property. but i do not get how to customize the Content for that.
i only need to fill three of total 8 in ...
so table Looks basically like this:
<div class="table-responsive">
<table class="table table-bordered" id="tblKontoauszug">
<thead>
<tr>
<th data-sortable="#sortable" data-sorter="dateSorter">Buchungsdat.</th>
<th data-sortable="#sortable">Belegnr.</th>
<th data-sortable="#sortable">BA</th>
<th data-sortable="#sortable" data-sorter="betragSorter">Betrag</th>
<th data-sortable="#sortable">Buchungstext</th>
<th data-sortable="#sortable">Gegenkontoart</th>
<th data-sortable="#sortable">Gegenkonto</th>
<th data-sortable="#sortable">Bezeichnung</th>
</tr>
<tr class="info text-bold">
<td>
#if ( Model.Zeilen.Count() > 0 )
{
<span>#Model.Zeilen.Min(b => b.Buchungsdatum).ToShortDateString()</span>
}
</td>
<td colspan="2">Anfangsbestand</td>
<td class="text-right">#Model.Anfangsbestand.ToString("N")</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</thead>
<tfoot>
<tr class="info text-bold">
<td>
#if ( Model.Zeilen.Count() > 0 )
{
<span>#Model.Zeilen.Max( b => b.Buchungsdatum ).ToShortDateString()</span>
}
</td>
<td colspan="2">Endbestand</td>
<td class="text-right #( Model.Endbestand < 0 ? "negative" : "")">#Model.Endbestand.ToString( "N" )</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tfoot>
<tbody>
#foreach ( var zeile in Model.Zeilen )
{
<tr>
<td>#zeile.Buchungsdatum.ToShortDateString()</td>
<td>#zeile.Belegnummer</td>
<td title="#zeile.BelegartText">#zeile.Belegart</td>
<td class="text-right #( zeile.Betrag < 0 ? "negative" : "")">#zeile.Betrag.ToString("N")</td>
<td>#zeile.Buchungstext</td>
<td>#zeile.Gegenkontoart</td>
<td>#zeile.Gegenkonto</td>
<td>#zeile.Bezeichnung</td>
</tr>
}
</tbody>
</table>
</div>

You can customize content in the footer by adding the data-footer-formatter attribute to the column you want to add the footer to and setting that attribute equal to a defined javascript function. Here's an example:
HTML:
<table data-toggle="table" data-show-footer="true" data-footer-style="footerStyle" data-show-columns="true">
<thead>
<tr>
<th data-sortable="true" data-footer-formatter="totalText">Name</th>
<th data-sortable="true" data-footer-formatter="carsSum"># Cars</th>
</tr>
</thead>
<tbody>
<tr>
<td>Johnny</td>
<td>2</td>
</tr>
<tr>
<td>Zack</td>
<td>3</td>
</tr>
<tr>
<td>Timmy</td>
<td>2</td>
</tr>
</tbody>
</table>
Javascript:
function totalText(data) {
return 'TOTAL';
}
function carsSum(data) {
return '7';
}
function footerStyle(value, row, index) {
return {
css: { "font-weight": "bold" }
};
}
Notice I'm not using <tfoot> at all here. That is because <tfoot> won't work with the show columns dropdown list but this will (if I were to use the data-show-columns="true" attribute on the <table> element as I did in the example above). You can also style the footer using the data-footer-style attribute. In my example, I'm making all text in the footer bold.
You can see the code in action here: https://jsfiddle.net/3mou92px/9/

Related

Bootstrap Table column header not aligned

<table class="table">
<thead>
<tr class="d-flex">
<th class="col-0">JOB ID</th>
<th class="col-0">JOB STATUS</th>
<th class="col-0">USER</th>
<th class="col-0">BG TASK STATUS</th>
<th class="col-2">BG TASK RESULT</th>
<th class="col-0">BG TASK CREATED TIME</th>
<th class="col-0">BG TASK COMPLETED TIME</th>
<th class="col-0">DETAIL LOG LINK</th>
</tr>
</thead>
<tbody>
<tr class="d-flex">
<td class="col-0">15</td>
<td class="col-0">success</td>
<td class="col-0">None</td>
<td class="col-0"></td>
<td class="col-2"></td>
<td class="col-0"></td>
<td class="col-0"></td>
<td class="col-0">Job Details</td>
</tr>
</tbody>
</table>
Delete the className="d-flex" in tr tag
You can add the class text-justify to the table so that the text will be aligned to center

Bootstrap: How to make table inside another table responsive with horizontal scrollbars on mobile devices?

I'm aware of table-responsive class but it's not working here and it's breaking the UI.
My code looks like this:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<table id="home-table">
<tr>
<td class='home-cell'>
<table class="table table-bordered">
<caption>Overview</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Last Reading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Demo 1</td>
<td>Reading: R1</td>
</tr>
</tbody>
</table>
</td>
<td class='home-cell'>
<table class="table table-bordered">
<caption>Alarms and Schedules</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dev 1</td>
<td>Scheduled 10:00 AM OFF</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
How can I achieve separate responsive horizontal scrollbars in both the tables inside the main table?
you can do it like this
<style>
.home-cell.table-responsive {
width: 150px;
overflow: auto !important;
display: inline-block;
}
table .table-bordered {
width: 190px;
min-width: 270px;
}
</style>
<table id="home-table">
<tbody>
<tr>
<td class="home-cell table-responsive">
<table class="table table-bordered">
<caption>Overview</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Last Reading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Demo 1</td>
<td>Reading: R1</td>
</tr>
</tbody>
</table>
</td>
<td class="home-cell table-responsive">
<table class="table table-bordered">
<caption>Alarms and Schedules</caption>
<thead>
<tr>
<th>Device ID</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dev 1</td>
<td>Scheduled 10:00 AM OFF</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Try this, This will work
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="table-responsive">
<table class="table table-bordered">
<th colspan="3">Outer Table</th>
<tr>
<td>This is row one, column 1</td>
<td>This is row one, column 2</td>
<td>
<table class="table table-bordered">
<th colspan="3">Inner Table</th>
<tr>
<td>This is row one, column 1</td>
<td>This is row one, column 2</td>
<td>This is row one, column 3</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
https://jsfiddle.net/DTcHh/38830/

How do I target a first-child that is visible (after children that are set to display:none), with only CSS

I need to target the first <td> element in a table row that is visible--meaning it does not have inline styling of display:none.
Here's the gotchyas:
They are not always hidden
Sometimes more than one is hidden.
I can't edit the HTML or use javascript/jQuery--This needs to be a pure CSS solution (hopefully)
Here is a quick sample of what the code looks like:
<table>
<thead>
<tr>
<th style="display:none">Header1</th>
<th>Header2</th>
<th>Header3</th>
<th>Header4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="display:none">Body1</td>
<td>Body2</td>
<td>Body3</td>
<td>Body4</td>
</tr>
</tbody>
</table>
I tried messing with something like this to no avail:
table > tbody > tr > td:first-of-type:not([style*="display:none"])
Here's a fiddle to mess with
Thanks in advance.
If your hidden elements are always at the beginning of the row, you can use the direct sibling selector for this +.
td:first-child,
td[style*="none"] + td {
color: red;
}
<table>
<thead>
<tr>
<th style="display:none">Header1</th>
<th>Header2</th>
<th>Header3</th>
<th>Header4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="display:none">Body1</td>
<td>Body2</td>
<td>Body3</td>
<td>Body4</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
<tr>
<td style="display:none">and</td>
<td>here's</td>
<td>an</td>
<td style="display:none">edge</td>
<td>case</td>
</tr>
</tbody>
</table>
This will style anything that isn't "display:none", but undo that when it gets to a subsequent "display:none".
table > tbody > tr > td:not([style*="display:none"]) {
color: red;
}
table > tbody > tr > td:not([style*="display:none"]) ~ td:not([style*="display:none"]) {
color: inherit;
}
<table>
<thead>
<tr>
<th style="display:none">Header1</th>
<th>Header2</th>
<th>Header3</th>
<th>Header4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="display:none">Body1</td>
<td>Body2</td>
<td>Body3</td>
<td>Body4</td>
</tr>
<tr>
<td>First</td>
<td>Second</td>
<td>Third</td>
</tr>
</tbody>
</table>

Add margin to Bootstrap 3 table?

I have a Bootstrap 3 table inside a div. It is defined like this:
<div id="todays-table">
<table class="table">
<thead>
<tr>
<th>Train Number</th>
<th>Status</th>
<th>Last Attempt</th>
</tr>
</thead>
<tbody>
<tr class="danger">
<td>2001</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2005</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="success-row">
<td>2006</td>
<td>1</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2007</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2008</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2009</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2010</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2011</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2012</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
<tr class="danger">
<td>2013</td>
<td>0</td>
<td>2015-05-12 11:25:16</td>
</tr>
</tbody>
</table>
</div>
The problem is there is no padding on the table and it goes to the very edges of the web browser like this:
How do I add padding to this bootstrap table? I tried <div id="todays-table" style="padding: 20px;"> and table { padding: 20px; }, neither of which worked. Can someone point in the right direction on how to do this please?
You want margin, not padding:
#todays-table {
margin: 20px;
}
Demo
Better, set styles on a reusable class:
.padded {
margin: 20px;
}
<div id="todays-table" class="padded">
That said, Bootstrap's grid system does a nice job of that type of thing without additional CSS:
<div class="container-fluid">
<div class="row">
<div class="col-xs-12" id="todays-table">
Demo 2
http://getbootstrap.com/css/#grid
Try adding some styles to the tds themselves
div#todays-table > table.table td {
padding: 20px;
}
EDIT
Just re-read the question, this should be more what you are after:
div#todays-table > table.table {
margin: 20px;
}

Nested table not displaying in IE7

I have a nested table inside a table which is nestedTable and it does not show up in IE7 even though it exists in the html and display is not none. Below is my html which seems to be valid and working in Firefox, Chrome and IE8:
<table id="myTable">
<thead> ... </thead>
<tbody class="myTbody1">
<tr class="details">
<td>
<table id="nestedTable">
<thead>
<tr>
<th> Col1 </th>
<th> Col2 </th>
</tr>
</thead>
<tbody class="head">
<tr class="nestedRow">
<td> Data</td>
<td> Data</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
<tbody class="myTbody2">..</tbody>
<tbody class="myTbody3">..</tbody>
</table>

Resources