// ROW EXPANDER CONSTRUCT =================================================================
var $table = $('#testTable');
$table.on('expand-row.bs.table', function(e, index, row, $detail) {
var res = $("#desc" + index).html();
$detail.html(res);
});
$table.on("click-row.bs.table", function(e, row, $tr) {
// Get selected row
var tbl = document.getElementById("testTable");
if (tbl != null) {
for (var i = 0; i < tbl.rows.length; i++) {
tbl.rows[i].onclick = function () { getRowVal(this); };
}
}
function getRowVal(row) {
var rowVal = parseInt(row.rowIndex);
var rowVal = rowVal-1
console.log('Row selected - '+ rowVal)
if ($tr.next().is('tr.detail-view')) {
$('.spanEdit').attr('class', 'spanEdit');
$table.bootstrapTable('collapseRow', $tr.data('index'));
}
else {
$('.spanEdit').attr('id', 'desc'+rowVal);
$table.bootstrapTable('expandRow', $tr.data('index'));
}
}
});
</div>
<div class="table" >
<table id="testTable"
class="table table-striped pagination-primary
table-hover
table-responsive"
data-toggle="table"
data-show-export="true"
data-pagination="false"
data-search="true"
data-detail-view="true"
data-show-refresh="true"
data-click-to-select="true">
<!-- <caption>List of users</caption> -->
<thead class="thead-dark">
<tr>
<th data-field="Client_ID" data-visible="false">Client_ID </th>
<th data-field="Salutation" data-sortable="true">Title</th>
<th data-field="FirstName" data-sortable="true">First Name</th>
<th data-field="Surname" data-sortable="true">Surname</th>
<th data-field="Tel" data-sortable="true">Tel</th>
<th data-field="Email" data-sortable="true">Email Address</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>other content</td>
<span class="spanEdit"style="display: none;" id="desc3">
<div id="expanderWrap" class="ExpanderWrap"><h4>Description:</h4>
<br>
<div id="expanderContainer" class+"expContainer">
This is row with id=0, containing other content
<p>I think that’s a responsibility that I have, to push possibilities, to show people, this is the level that things could be at. So when you get something that has the name Kanye West on it, it’s supposed to be pushing the furthest possibilities. I will be the leader of a company that ends up being worth billions of dollars, because I got the answers. I understand culture. I am the nucleus.</p>
</div>
</div>
</span>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="tab-pane" id="messages" role="tabpanel">
<p>I think that’s a responsibility that I have, to push possibilities, to show people, this is the level that things could be at. So when you get something that has the name Kanye West on it, it’s supposed to be pushing the furthest possibilities. I will be the leader of a company that ends up being worth billions of dollars, because I got the answers. I understand culture. I am the nucleus.</p>
</div>
<div class="tab-pane" id="settings" role="tabpanel">
<p>
"I will be the leader of a company that ends up being worth billions of dollars, because I got the answers. I understand culture. I am the nucleus. I think that’s a responsibility that I have, to push possibilities, to show people, this is the level that things could be at."
</p>
</div>
</div>
</div>
</div>
</div>
// ROW EXPANDER CONSTRUCT =================================================================
var $table = $('#testTable');
$table.on('expand-row.bs.table', function(e, index, row, $detail) {
var res = $("#desc" + index).html();// the html of the span is what is being passed as a string to the expanded row.
$detail.html(res);
});
$table.on("click-row.bs.table", function(e, row, $tr) {
// Get selected row
var tbl = document.getElementById("testTable");
if (tbl != null) {
for (var i = 0; i < tbl.rows.length; i++) {
tbl.rows[i].onclick = function () { getRowVal(this); };
}
}
// Get the clicked row value using this function
function getRowVal(row) {
var rowVal = parseInt(row.rowIndex);
var rowVal = rowVal-1
console.log('Row selected - '+ rowVal)
if ($tr.next().is('tr.detail-view')) {
// the row value that is obtained above is passed in the code below to provide the 'index'
$('.spanEdit').attr('id', 'desc'+rowVal); // this is the value that is passed to the index below
$table.bootstrapTable('collapseRow', $tr.data('index')); // this index is then used to collapse the required row
}
else {
$('.spanEdit').attr('id', 'desc'+rowVal); // again rowVal is passed to the index and this expands the row
$table.bootstrapTable('expandRow', $tr.data('index'));
}
}
});
if($('tr').className!=='collapse'){
$('tr').addClass('collapse');
}
Could you post the HTML-CSS code of the table?