Bootstrap: Maintain table size fixed horizontally during collapse/expand - html

I have a really long text in one of the column of my table. So I am using bootstrap provided collapse/expand button to hide/show that long text (cell data).
But when I click on the button to collapse/expand the text, the table flickers and gets resized horizontally.
How do I prevent the table columns from re-sizing horizontally during collapse/expand of that table data ? And allow the expansion of text ONLY vertically limited within that column width ?
Below is the HTML for reference.
<table id="query_table" class="table table-bordered table-striped table-hover">
<thead>
<th>ID</th>
<th>Name</th>
<th>Topic</th>
<th>Description</th>
</thead>
<tbody>
<tr>
<td>9</td>
<td>ORDER_ZONE</td>
<td>2018-06-18 21:47:31.0</td>
<td>
<button class="btn btn-primary" type="button" data-toggle="collapse"
data-target="#collapseExample_9" aria-expanded="true"
aria-controls="collapseExample_9">
Show/hide Description
</button>
<div class="collapse" id="collapseExample_9">
<div class="card card-body">
SOME VERY VERY VERY VERY LONG TEXT HERE
</div>
</div>
</td>
</tr>
<tr>
<td>9</td>
<td>ORDER_ZONE</td>
<td>2018-06-18 21:47:31.0</td>
<td>
<button class="btn btn-primary" type="button" data-toggle="collapse"
data-target="#collapseExample_10" aria-expanded="true"
aria-controls="collapseExample_10">
Show/hide Description
</button>
<div class="collapse" id="collapseExample_10">
<div class="card card-body">
ANOTHER VERY VERY VERY VERY LONG TEXT HERE
</div>
</div>
</td>
</tr>
</tbody>
</table>

Use table-layout: fixed css for your table and you might have to give some fixed width for table itself and/or its cells.

Related

HTML Table wrap col data to fit to the view

Have a question about the HTML view related to the table.
In my HTML view, I have a table.
This is worked in a responsive way when changing the view.
Here I want to change the view that the responsive view comes with a scroll bar.
I want to change it to fit all columns to the view and wrap the column contents.
Any suggestions to do it?
<div class="col-md-12 col-sm-12 grid-margin stretch-card">
<div class="card shadow-card-l">
<div class="card-body">
<center><h4 class="card-title">Task Related Documents</h4></center>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Document Type</th>
<th>Document Note</th>
<th>File Name</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model.TaskFilesHistoryViewModel.OrderByDescending(x => x.Id))
{
<tr class="even pointer">
<td>#item.File_Type</td>
<td>#item.Note</td>
<td>#item.File_Name</td>
<td>
<a href="#Url.Action("DownloadTaskImage","Ajax", new { id = item.Id})" target="_blank" rel="publisher tag" class="btn btn-outline-info ti-import" />
<a href="#Url.Action("RetrieveTaskImage","Ajax", new { id = item.Id})" target="_blank" rel="publisher tag" class="btn btn-outline-success fa ti-eye" />
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
</div>

Parent div issue in datepicker

While clicking date picker icon it navigates to the bottom of the table.because it's not fit to the td tag,
So it searching for next parent div tag.The next div tag is a table.So it navigates to the bottom of the table. any solution for that.
Actually, after clicking the icon, it navigates to the bottom. Again I need to scroll up to see the date picker
After click icon
after i need to scroll up to see the date picker
HTML:
<div class="row grid-main m-0">
<div class="col-md-12">
<div class="grid-table table-responsive">
<table class="table">
<thead>
<tr>
<th> {{'911_LBL_MONTH' | translate}}</th>
<th>{{'911_LBL_FRMDATE' | translate}} <sup class="required">*</sup></th>
<th>{{'911_LBL_TODATE' | translate}} <sup class="required">*</sup></th>
<th>
<sortable-header [headerText]="'911_LBL_UPDATEDBY'" [sortField]="'ModifiedBy'" [items]="applicationdetail" (changeCurrentSortField)="changeCurrentSortField($event)"
[currentSortField]="currentSortField"></sortable-header>
</th>
<th>
<sortable-header [headerText]="'911_LBL_LASTUPDATED'" [sortField]="'ModifiedDate'" [items]="applicationdetail" (changeCurrentSortField)="changeCurrentSortField($event)"
[currentSortField]="currentSortField"></sortable-header>
</th>
<th class="text-center">{{'911_LBL_APPCOUNT' | translate}} </th>
</tr>
</thead>
<tbody>
<ng-template [ngTemplateOutlet]="tmpltTbl"
[ngTemplateOutletContext]="{ $implicit: itm, idx: i }"></ng-template>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<ng-template #tmplt let-item>
<tr *ngFor="let item of applicationdetail; let i = index">
<td>{{montharray[i] | translate}}</td>
<td *ngIf="item.FromDate">
<div>
<app-date [inputDate]="item.FromDate" [index]="i"
(emitDate)="assignFromDate($event,i)"
[minDate]="minDate[i]"
[maxDate]="maxDate[i]"
[isDisabled]="item.DisablePassedFromDate"
controlName="FromDate{{i}}"
[isConditional]="true"></app-date>
</div>
</td>
<td *ngIf="item.ToDate">
<div>
<app-date [inputDate]="item.ToDate" [index]="i"
(emitDate)="AssignToDate($event,i)"
[minDate]="toMinDate[i]"
[maxDate]="toMaxDate[i]"
[isDisabled]="item.DisablePassedToDate || item.FromDate==null"
controlName="ToDate{{i}}"
[isConditional]="true"></app-date>
</div>
</td>
<td> {{isEnglish ? item.ModifiedBy : item.ModifiedBy_AR}} </td>
<td>{{item.ModifiedDate}}</td>
<td class="text-center"><button type="submit" class="btn btn-primary btn-radius" (click)="openDialog(this.item,i)" data-backdrop="static" data-toggle="modal" data-keyboard="false" data-target="#myModal" value="submit" title="{{'CMN_BTN_MANAGETITLE' | translate}}">{{'911_LBL_MANAGE' | translate}} </button></td>
</tr>
</ng-template>
Thanks in advance
So it searching for next parent div tag.The next div tag is a table.So it navigates to the bottom of the table. any solution for that.
As I understand you find, that problem in the parent div tag, that is far away from your datepicker showing place.
So you can add second parent div where you want it.
For example:
<div style="position: relative;">
<div style="position: relative;">
<app-date [inputDate]="item.FromDate" [index]="i"
(emitDate)="assignFromDate($event,i)"
[minDate]="minDate[i]"
[maxDate]="maxDate[i]"
[isDisabled]="item.DisablePassedFromDate"
controlName="FromDate{{i}}"
[isConditional]="true"></app-date>
</div>
</div>
Don't forget to try with position: relative; - It also can be reason of problem.

Aligning two divs in bootstrap

My intention is to align the boxplot with the textual content.
Here is the page of my BOXPLOT visualization
The following is the html code that makes the page appear, where the visulization is represented by the id boxplot. Demo.
I can invert the visualization but I cannot align it with the textual content. I looked up the bootstrap settings and placed it in different locations, but it always ended up coming in front of the text. I am not well-versed with css styling. Can anybody help?
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script><script src="https://code.highcharts.com/modules/exporting.js"></script>
<div class="container">
<h1>Where's the plag?</h1>
<div class="jumbotron">
<small>
<p>Atom Type: paragraph </p>
<p>Cluster Method: kmeans </p>
<p>k: 2 </p>
Stylistic Feature(s):
<p>honore_r_measure </p>
<p></p>
</small>
<br>
<div id='chart' style="height: 300px; width: 20000px"></div>
<br>
<button type="button" class="btn btn-primary btn-sm" data-toggle="collapse" data-target="#full_table">
Hide/Show Table
</button>
<div class="row collapse in" id="full_table">
<div class="col-md-9">
<div class="table-responsive" style="font-size:12px;">
<table class="table table-condensed table-scrollable table-bordered">
<thead>
<tr>
<th>Start Index</th>
<th>honore_r_measure</th>
<th>Suspicion Score</th>
</tr>
</thead>
<tbody>
<tr class="passage_starting_at_">
<td class="passage_row"> 0</td>
<td class="passage_row"> 2512.6585</td>
<td class="passage_row">0.0000</td>
</tr>
<tr class="passage_starting_at_">
<td class="passage_row"> 196</td>
<td class="passage_row"> 2115.8163</td>
<td class="passage_row" bgcolor=#F60C0C> 1.0000</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row">
<br class="col-md-9">
<div class="panel panel-default">
<!-- Change the id of the following div to either column or boxplot, whichever is required-->
<div id="boxplot" style="height: 300px; width: 750px"></div>
<div class="panel-heading">
easy_source
</div>
<div class="panel-body" id="document_content">
<p>
<div class="passage" features="<p>Span</p><p>0, 194</p><hr size = "10"<p>Plag. conf.</p><p>0.0</p><hr size = "10"<p>PLAG SPAN</p><p>No plag!</p><hr size = "10"<p>honore_r_measure</p><p>2512.6585</p><hr size = "10""
style="font-size:14px;display:inline;;color:rgb(0,0,0);" id='pass0'>
This is a really short source that isn't all that super exciting. It should have some nice fingerprints that hopefully match its plagiarized copy which is named easy_test.txt. Pretty cool stuff.
</div>
<br/>
<div class="passage" features="<p>Span</p><p>196, 379</p><hr size = "10"<p>Plag. conf.</p><p>1.0</p><hr size = "10"<p>PLAG SPAN</p><p>No plag!</p><hr size = "10"<p>honore_r_measure</p><p>2115.8163</p><hr size = "10""
style="font-size:14px;display:inline;color:rgb(255,0,0);" id='pass1'>
It also has another couple of lines which are not in the test document but are also here and are very exciting. This will make jaccard similarity not quite 1.0 but probably about 0.6.
</div>
<br/>
</div>
</div>
</div>
</div>
basically, I want the diagram to be like this

twitter bootstrap html tool-tip oddness

I'm trying to add html tool-tips to an existing page that's made of a table on one side of the page and something else on the other. I want to add the tool-tip to each td in the table.
With the tool-tip added to each td every time I hover over a td the whole table shifts over one cell!
Also, tried only on chrome.
before the hover
And when I hover over the first td
Below is a cut down, but fully working example of the oddness, any thoughts appreciated.
<!DOCTYPE html>
<html>
<head lang="en">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="shortcut icon" href="static/img/favicon.ico" type="image/x-icon" />
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<div class="table-responsive" id="23">
<TABLE class="table table-bordered table-nonfluid">
<tr id="hdr" class="bg-primary h5">
<th class="text-center">Mon 18 May</th>
<th class="text-center">Thu 21 May</th>
</tr>
<tr id="day" class="text-center">
<td class="bg-danger"
data-trigger="hover"
data-placement="auto"
data-html="true"
data-title="<div>WHAT!</div>"
data-toggle="tooltip"
>
<sup>300</sup>/<sub>312</sub>
</td>
<td class="bg-danger"
data-trigger="hover"
data-placement="auto"
data-html="true"
data-title="<div>WHAT!</div>"
data-toggle="tooltip"
>
<sup>277</sup>/<sub>312</sub></td>
</tr>
</TABLE>
</div>
</div>
<div class="col-md-6 " style="padding-top: 16px;">
<blockquote id="comment_txt">before, after and then on</blockquote>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script>
$( document ).ready(function() {
$('[data-toggle="tooltip"]').tooltip()
});
</script>
</body>
</html>
I suggest to wrap the content of your td inside a span like this
<td><span data-trigger="hover" style="display:block"
data-placement="auto"
data-html="true"
data-title="<div>WHAT!</div>"
data-toggle="tooltip"><sup>300</sup>/<sub>312</sub></span></td>
Is never a good idea using the tooltips directly on a table element.
Well this is a weird issue actually. Never realised it until now. This might not be the perfect fix but a temporary fix will be to place a span around the text in the td for the one on the left and for the td on the right leave it as it is right now because it works fine only the left one causes this issue.
Bootply Link right here
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<div class="table-responsive" id="23">
<TABLE class="table table-bordered table-nonfluid">
<tr id="hdr" class="bg-primary h5">
<th class="text-center">Mon 18 May</th>
<th class="text-center">Thu 21 May</th>
</tr>
<tr id="day" class="text-center">
<td class="bg-danger" >
<span data-trigger="hover"
data-placement="auto"
data-html="true"
data-title="WHAT!"
data-toggle="tooltip">
<sup>300</sup>/<sub>312</sub>
</span>
</td>
<td class="bg-danger"
data-trigger="hover"
data-placement="auto"
data-html="true"
data-title="<div>WHAT!</div>"
data-toggle="tooltip"
>
<sup>277</sup>/<sub>312</sub></td>
</tr>
<tr id="day" class="text-center">
<td class="bg-danger" >
<span data-trigger="hover"
data-placement="auto"
data-html="true"
data-title="WHAT!"
data-toggle="tooltip">
<sup>300</sup>/<sub>312</sub>
</span>
</td>
<td class="bg-danger"
data-trigger="hover"
data-placement="auto"
data-html="true"
data-title="<div>WHAT!</div>"
data-toggle="tooltip"
>
<sup>277</sup>/<sub>312</sub></td>
</tr>
</TABLE>
</div>
</div>
<div class="col-md-6 " style="padding-top: 16px;">
<blockquote id="comment_txt">before, after and then on</blockquote>
</div>
</div>
</div>
The problem with my fix is simple. The tooltip will only show on the left td if you hover on the text in the cell not on the table-cell itself whilst the tooltip will show if you hover on the table cell on the right. bad for user experience I know but this is as i said a temporary fix.

Bootstrap 2.3.2 split button dropdowns in tables line

The dropdown on the right is in a table cell, this works as intended on desktop browser.
However on mobile, on click, the dropdown gets split into two lines:
HTML
<table class="table table-striped table-bordered table-hover">
<tr>
<td> ... </td>
<td> ... </td>
<td> ... </td>
<td>
<div class="btn-group">
<i class="icon-eye-open icon-white"></i> Visualizza
<button class="btn dropdown-toggle btn-primary btn-small" data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><i class="icon-pencil"></i> Modifica</li>
<li><a class="btn-confirm" href="#"><i class="icon-trash"></i> Elimina</a></li>
</ul>
</div>
</td>
</tr>
</table>
The problem most likely stems from the table cell width being laid out too short for both elements.
The simplest solution would be to set add a class to that cell and add min-width, though you would be moving away from pure bootstrap.
HTML:
<td> ... </td>
<td class="dropdownCell">
<div class="btn-group">
...
Css:
.dropdownCell { min-width:130px; }
Fiddle is here: http://jsfiddle.net/a4kx75t1/1/