DataTables and Responsive Design
DataTables and Responsive Design
I've been reading up on responsive design and am trying to implement it with DataTables. See here... http://filamentgroup.com/lab/responsive_design_approach_for_complex_multicolumn_data_tables/
I sort of got it to work. When resizing the browser window, the columns get hidden. But when I try to filter the data, the column headers don't appear but the data does. I want the whole column to be hidden.
I'm thinking that the best way to go about this is purely in DataTables but I don't know where to start. Any help would be appreciated.
I sort of got it to work. When resizing the browser window, the columns get hidden. But when I try to filter the data, the column headers don't appear but the data does. I want the whole column to be hidden.
I'm thinking that the best way to go about this is purely in DataTables but I don't know where to start. Any help would be appreciated.
This discussion has been closed.
Replies
Allan
But I'm thinking this is not the right way and I will need to do something similar purely with DataTables and the APIs. But I'm not sure where to start.
So you'd probably need to use a resize event handler and add / remove columns with the API method as required by the space available.
Allan
$(document).ready(function(){
//If the User resizes the window, adjust the #container height
$(window).bind("resize", resizeWindow);
function resizeWindow( e )
{
var newWindowWidth = $(window).width();
//var newWindowHeight = $(window).height();
//$("#container").css("min-height", newWindowHeight );
if(newWindowWidth > 1024)
{
/* Do Something */
}
elseif((newWindowWidth >= 600) && (newWindowWidth <= 1024))
{
/* Do Something */
oTable.fnSetColumnVis( 1, false );
}
elseif(newWindowWidth < 600)
{
/* Do Something */
oTable.fnSetColumnVis( 1, false );
oTable.fnSetColumnVis( 2, false );
oTable.fnSetColumnVis( 3, false );
}
/* Display Width & Height */
//$("#W").text(newWindowWidth);
//$("#H").text(newWindowHeight);
}
});
Source : http://www.snipplr.com/view.php?codeview&id=9097