DataTable horizontal scrolling with jquery Mobile not working - css
When using datatables with jquery mobile, I can not seem to get a horizontal scroller going. I have tried every combination of sScrollX and sScrollY I can think of.
To see an example of the lack of vertical scroller, please try the webapp example I put up here.
On an iphone or some other small screen try the following:
1) Switch the slider from Graph to Table
2) Hit the favorites button
3) Scroll down the left panel and select "MSFT".
You will see only the first few columns. You can scroll up and down but not to the right.
I tried sScrollX and sScrollY but the scrolling is then inconsistent and buggy. At the moment I've disabled both and at least vertical scrolling works ok.
Any help would be much appreciated as I've now been fighting this for a week!
Please find the current datatables code below:
var table = $('#table_container').dataTable( {
"symbol": symbol,
"exchange": exchange,
"aoColumns": columnData,
"aoColumnDefs": [
{ "aTargets": [0], "mRender": function (data, type, full) {return dateFormat(data)} },
{ "aTargets": [1], "mRender": function (data, type, full) {return volumeNumber(data)} },
{ "aTargets": [8], "mRender": function (data, type, full) {return volumeNumber(data)} },
{ "aTargets": [14], "mRender": function (data, type, full) {return volumeNumber(data)} },
{ "aTargets": ["_all"], "mRender": function (data, type, full) {return numberWithCommas(parseFloat(data).toFixed(2))} },
],
"aaSorting": [[ 0, "desc" ]],
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bInfo": false,
"bAutoWidth": false,
"bProcessing": true,
//"sScrollX": "100%",
//"sScrollY": "100%",
//"sDom": 'r<"H"lf><"datatable-scroll"t><"F"ip>',
"bScrollCollapse": false,
"bServerSide": true,
"sAjaxSource": str,
"bDeferRender": true,
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
}
} );
Try like this
$(document).ready(function() {
$('#example').dataTable( {
"sScrollX": "100%",
"sScrollXInner": "110%",
"bScrollCollapse": true
} );
} );
Refer this Fiddle Demo
Wrap the table in a div.
You can set the overflow value to auto.
<div class="table-container">
<table>
...
</table>
</div>
CSS
.table-container{
overflow: auto
}
another way is to set the overflow to hidden, and then set the overflow-x (horizontal scrolling) to scroll. This has the benefit of also allowing you to set the -webkit-overflow-scrolling to touch, which will allow for momentum scrolling on mobile devices.
CSS
.table-container{
overflow: hidden;
overflow-x: scroll;
-webkit-overflow-scrolling: touch;
}
I have inspected the CSS of your APP from the link you provided.
To get the table to scroll in any direction independently you will need to set a desired width and height in your .dataTables_wrapper class. Vertical scrolling works in your APP because the Table is not actually scrolling itself but the Whole Page is. If your APP will not have any other content below the table then the table height can be set all the way to the bottom of the Page or else you will need to have a small Gap at the bottom so a user can touch and scroll further down the Page. Also If you are aiming your app on different mobiles then you need some jquery code to calculate screen size and update the width and height in the .dataTables_wrapper class on the fly so the table will fit the screen from left and right and to the bottom. Any excess width and height will be scrolled if the table contents are longer than the size. If the APP is just for one mobile then its easy to play around with the width and height in the class to get the desired size of the table.
Example
.dataTables_wrapper {
position: relative;
clear: both;
height: 400px;
width: 400px;
overflow: scroll;
-webkit-overflow-scrolling: touch;
}
Your main_container css should be like this, so delete the rest. Otherwise you will have another horizontal scroll bar that does nothing.
#main_container {
overflow: hidden;
}
Although scroll bars are usually hidden from mobile browsers unlike desktop browsers, if you want add this css trick to hide them from view. This trick only works for webkit browsers such as Google/Safari/Native Android etc.
::-webkit-scrollbar {
width: 0px;
}
It may be a good idea to you have Fixed Table Header so a person can see what data relates to the columns when they are scrolling. There are lots of ways to achieve this, below i added a link i found
http://fixedheadertable.com/
Related
Material-UI how to manipulate styles for DialogContent and Dialog?
Currently I am facing an awkward situation: I want to make the dialogContent's overflow: auto so my modal becomes scrollable if the content exceed the height of the dialog. However, there's a dropdown menu that I'd like it to display normally, but because overflow: auto, I have to not only scroll down the dropdown menu, but also the dialog itself. Can someone help me with this? const dialogStyle = makeStyles((theme: Theme) => createStyles({ root: { width: '100vw', }, dialog: { overflow: 'visible', }, dialogContent: { overflow: 'auto', }, }), )
For anyone who might have the same issue - I figured the answer myself. So.. The best way to resolve this, is to add an attribute: <Dialog scroll='body' /> and keep the both dialog and dialogContent's overflow as visible.
How to hide legends in highcharts in mobile view alone
I need to hide legends of highcharts ng in mobile view alone so that it occupies the full width of the screen. I tried setting the class .highcharts-legend to display none using bootstrap class hidden-xs but even though it is getting hidden the chart is not occupying the full width of the screen even though the highcharts ng directive does. I have also given the id #chart1 as follows #chart1{ height:100% !important; width:100% !important; } so that the chart always occupies the full width of the screen
This will work to hide legend if screen less than 900px: chart.legend.update({ enabled: (chart.containerWidth > 900) }); Likewise: legend: { enabled : ($('#myContainer').width() > 900) }
You can use responsive property and hide the legend in some condition: responsive: { rules: [{ chartOptions: { legend: { enabled: false } }, condition: { maxWidth: 500 } }] } Live demo: http://jsfiddle.net/BlackLabel/pds7aqr4/ API Reference: https://api.highcharts.com/highstock/responsive
bootstrap 3 - not pushing footer to the bottom of page
I received a task at work to create some mini-webpage layout with bootstrap. I decided to base on already done layout (Amoeba). Here is the preview: Amoeba bootstrap link Well, on localhost almost works except one thing - footer. Just take a look on provided link and then: click Portfolio (from navigation) and then filter the gallery by Photography. When you will scroll down you will see ugly space. And this is my issue. I dont want that. So i thought that I need a footer OR portfolio div class which will automatically resize to proper size. BUt I dont how how to achieve that. Any tips?
You need only to change the code of modernizr slightly. Change forceHeight to false and will work good. if (Modernizr.mq("screen and (max-width:1024px)")) { jQuery("body").toggleClass("body"); } else { var s = skrollr.init({ mobileDeceleration: 1, edgeStrategy: 'set', forceHeight: false, smoothScrolling: true, smoothScrollingDuration: 300, easing: { WTF: Math.random, inverted: function(p) { return 1-p; } } }); }
Im not sure why, but your body element gets some height inline styling. Anyways here is the solution of your problem: body { height:100% !important; // inline styles, so you need to add "!important" here position:relative; } #footer { position: absolute; width: 100%; bottom: 0px; } You can also add wrapper div if you don't want to add position:relative and height:100%!important properties to your body element. Just see how it works and choose a better option for you.
Resizing footer columns in ng-grid
I'm having a small issue with AngularJS and ng-grid. I want to add a row in the footer that contains total values for each column. Using a footer template I managed to do that, so far so good. Is there any way I can resize these columns based on the size of the grid's columns? Or at least set the row width to follow the width of the grid canvas? Thanks in advance.
By using CoulmnDefs and using the same widths in your footer template. $scope.gridOptions = { data: 'myData', enablePaging: true, showFooter: true, footerRowHeight:'30px', footerTemplate: '<div style="width: 20%; display: inline-block;">{{total1}}</div><div style="width: 60%; display: inline-block;">{{total2}}</div><div style="display: inline-block;">{{total3}}</div>', totalServerItems: 'totalServerItems', columnDefs: [{ field: 'name', width: '20%' }, { field: 'allowance', width: '60%' }, { field: 'paid' }], pagingOptions: $scope.pagingOptions, filterOptions: $scope.filterOptions }; This is based on old Plunker I found somwhere. If the grid gets to small this still goes bonkers. Try to set a minwidth for the grid in style.css or the for the columns in columnDefs and the footer template.
How to set up twitter's embedded timeline width in percentage (responsive/fluid design)
I'm looking to set up twitter's embedded timeline, it's quite easy when you're having a fixed design, but that's not my case and I'm actually building a fluid and responsive design for a new website. My question is, how can I set up twitter's embedded timeline with a fluid width since its an iframe and you're supposed to set up the with in px in your twitter account ? Thanks :)
This seems to work for me: #twitter-widget-0 { width:100%; } where #twitter-widget-0 is the iframe it generates, placed in an appropriately-styled container. It's not perfect: the widget generates its contents a bit differently depending on width, and margins, etc. won't be exactly the same after resizing; but this seems minor. I'm curious as to why simple CSS didn't work for you - sorry if I'm missing something.
Thanks to all of you I found my way through: It was almost as lack said, but we had to focus on the iframe instead: .MyClassForTheDivThatContainTheiFrame iframe{ width:100%; } of course .MyClassForTheDivThatContainTheiFrame is also fluid with a % width
This logic will work to change at least the width and height: #twitter-widget-0, #twitter-widget-1 { float: none; width: 100% !important; height: 250px !important; } The only problem with shortening the height is that it hides the text box for people to send tweets but it does shorten the height. My guess is that if you want to add other CSS styling you can just put the !important clause. I also assume that if you have three widgets you would define #twitter-widget-2, etc.
Super hacky, but you can also do this : <script type="text/javascript"> var checkTwitterResize = 0; function resizeTwitterWidget() { if ($('#twitter-widget-0').length > 0) { checkTwitterResize++; if ($('#twitter-widget-0').attr('width') != '100%') checkTwitterResize = 0; $('#twitter-widget-0').attr('width', '100%'); // Ensures it's checked at least 10 times (script runs after initial resize) if (checkTwitterResize < 10) setTimeout('resizeTwitterWidget()', 50); } else setTimeout('resizeTwitterWidget()', 50); } resizeTwitterWidget(); </script>
This was a helpful thread, thanks. I'm working on a site that uses an older Twitter profile Widget, which I find easier to customise. So an alternative method, uses this to display the feed (customised to suit): <script> new TWTR.Widget({ version: 2, type: 'profile', rpp: 5, interval: 6000, width: 300, height: 400, theme: { shell: { background: 'transparent', color: '#151515' }, tweets: { background: 'transparent', color: '#151515', links: '#007dba' } }, features: { shell: false, scrollbar: true, loop: false, live: true, hashtags: true, timestamp: true, avatars: true, behavior: 'all' } }).render().setUser('BlueLevel').start(); </script> Then override the width by adding this to your stylesheet: .twtr-doc { width:100% !important; } You can see the various classes to modify by using IE9 in compatibility mode, then using F12 Developer Tools to see the html/css. Hope that helps someone!
You can give your iframe a class, and try to apply CSS to it. At least to change the width to %.
This is not possible. You can set an exact width and height using the html width and height in the anchor tab. Other than that you are out of luck. No responsive or fluid capabilities. It also has a min-width of 220px and a max-width of 520px. <a class="twitter-timeline" width="520" height="700" data-dnt=true href="https://twitter.com/vertmob" data-widget-id="WIDGET_ID_HERE">Tweets by #vertmob</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
If you absolutely must do a fluid, you can code a javascript that changes that iframe's width after a resize event or using some javascript timers. Can we see some code of yours to make some js code for this?
Attribute selector should work: iframe[id*="twitter-widget"] { width: 100%; } More here.