I am new to data tables and never created a responsive data tables. So i may be asking much help.
Here is link for JQuery data tables editables. I want to create it resp
In responsive design most of the tricks done by percentage values until a certain point and after that we start using @media queries.
For your example just percentages used for the th and td tag I belive you can manage it but if it is smaller than 40em then completely different CSS take control like below;
//when width less than 40em you can also use px
@media (max-width: 40em)
{
// show every item as a line
.movie-list td, .movie-list th {
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
float: left;
clear: left;
}
//for th and .titles display them as a big bold title with different background color
.movie-list tbody th, .movie-list tbody td.title {
display: block;
font-size: 1.2em;
line-height: 110%;
padding: .5em .5em;
background-color: #fff;
color: #77bbff;
-moz-box-shadow: 0 1px 6px rgba(0,0,0,.1);
-webkit-box-shadow: 0 1px 6px rgba(0,0,0,.1);
box-shadow: 0 1px 6px rgba(0,0,0,.1);
}
//for th only this is only for margin to override previous css
.movie-list tbody th {
margin-top: 0;
text-align: left;
}
}
hope this help this is just give some start;
here your fish mate :) just use developer tool bar and add the code under the h2 Live Example tag;
<style>
// check if it is a small device ipad iphone android etc.
// google for example 'css media queries for mobile"
@media (max-width: 40em) {
// just did something to display second row use your skills
table#example tr.even
{
border: 2px solid red;
}
// exactly the same with other one to display td as rows
// with css selector you can hide first one display 2nd one like a title etc
table#example tr td
{
background-color:white;
width: 90%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
float: left;
clear: left;
}
// remove the thead as we dont need it
// you should do similar to the footer as well
table#example thead
{
display:none;
}
// hide unwanted pagination elements
table#example ~ div.fg-toolbar div#example_info,
table#example ~ div.fg-toolbar div a
{
display:none;
}
// and only display next and prev
// it s not what I actually wanted to make it more tab able make it bigger and try to cover half of the row.
table#example ~ div.fg-toolbar div a#example_previous,
table#example ~ div.fg-toolbar div a#example_next
{
display:inline-block;
width:46% !important;
}
}
</style>
As far as I can tell the edit and add stuffs are working as this is completely css just you have to dig deeper.
You can do it with jquery only. fnAdjustColumnSizing function automatically adjust the with of the headers. When you resize the window we use this funtion.
$(window).resize(function(){
//Redraw datable
$('#your-table').dataTable().fnAdjustColumnSizing();//Automatically sets header size
});