I followed @koala_dev's code in this post to try to lock the first column s my table scrolls horizontally. The code unfortunately has no effect on my table. I was wondering if anyone could give me some pointers on what I have done wrong as I am new to programming.
This is my table: http://jsfiddle.net/mademoiselletse/bypbqboe/59/
This is the code I inserted in JS (line 121-133):
$(function() {
var $tableClass = $('.table');
// Make a clone of our table
var $fixedColumn = $tableClass.clone().insertBefore($tableClass).addClass('fixed-column');
// Remove everything except for first column
$fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();
// Match the height of the rows to that of the original table's
$fixedColumn.find('tr').each(function(i, elem) {
$(this).height($tableClass.find('tr:eq(' + i + ')').height());
});
});
This is the CSS properties (line 36-47) I have inserted:
.table-responsive > .fixed-column {
position: absolute;
display: inline-block;
width: auto;
border-right: 1px solid #ddd;
}
@media(min-width:768px) {
.table-responsive>.fixed-column {
display: none;
}
}
The only thing I deviated from the demo code was that I defined $('.table')
as $tableClass
instead of $table
since I have previously defined var $table
as $('#table')
. Your help will be much appreciated!
$tableClass = $('.table');
i.e. you are trying to get your table object with reference to class but you have given yourtable
withid
astable
and notclassName
astable
– Edreitable
and why are removing all thetable data
andtable head
except first one?? – Edreicss
right?? whycloning
and again inserting and all for that?? – Edreitable
since you are loading it throughajax
request. What you can do is execute that piece of code like cloning and all, once all the table data has been loaded!! can you tell me the function name which loads the table data?? – Edreiabsolute
by inserting this in CSS but didn't work out: #table th:nth-child(1), #table td:nth-child(1), #table th:nth-child(2), #table td:nth-child(2){ position: absolute } – Xenophanesboostraptable
plugin will add some moredivs
before the table to make itresponsive
and you need to try to append it in the exact place! i.e. the example you have seen, hides the first header and column with a newly createdtable
which is very difficult to achieve in this!! anyways!! will give a try once!! – Edrei