
- jQuery Mobile Tutorial
- jQuery Mobile - Home
- jQuery Mobile - Overview
- jQuery Mobile - Setup
- jQuery Mobile - Pages
- jQuery Mobile - Icons
- jQuery Mobile - Transitions
- jQuery Mobile - Layouts
- jQuery Mobile - Widgets
- jQuery Mobile - Events
- jQuery Mobile - Forms
- jQuery Mobile - Themes
- jQuery Mobile - CSS Classes
- jQuery Mobile - Data Attributes
- jQuery Mobile Useful Resources
- jQuery Mobile - Interview Questions
- jQuery Mobile - Quick Guide
- jQuery Mobile - Useful Resources
- jQuery Mobile - Discussion
jQuery Mobile - Table Reflow
Description
You can represent the data in a horizontal format by collapsing the table into a stacked representation. This groups the rows into a vertical format using the data-mode = "reflow" attribute.
Example
Following example demonstrates the use of table reflow in the jQuery Mobile Framework.
<!DOCTYPE html> <head> <title>Table Reflow</title> <meta name = "viewport" content = "width = device-width, initial-scale = 1"> <link rel = "stylesheet" href = "http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src = "http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src = "http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role = "header"> <h2>Header</h2> </div> <table data-role = "table" id = "table_columns" data-mode = "reflow" class = "ui-responsive"> <thead> <tr> <th data-priority = "1">Position</th> <th>Team</th> <th data-priority = "2">Rating</th> <th data-priority = "3">Points</th> </tr> </thead> <tbody> <tr> <th>1</th> <td>SOUTH AFRICA</td> <td>114</td> <td>3308</td> </tr> <tr> <th>2</th> <td>INDIA</td> <td>110</td> <td>3535</td> </tr> <tr> <th>3</th> <td>AUSTRALIA</td> <td>109</td> <td>4376</td> </tr> <tr> <th>4</th> <td>PAKISTAN</td> <td>106</td> <td>2977</td> </tr> <tr> <th>5</th> <td>NEW ZEALAND</td> <td>99</td> <td>3578</td> </tr> <tr> <th>6</th> <td>ENGLAND</td> <td>99</td> <td>3940</td> </tr> <tr> <th>7</th> <td>SRI LANKA</td> <td>89</td> <td>3123</td> </tr> <tr> <th>8</th> <td>WEST INDIES</td> <td>76</td> <td>2504</td> </tr> <tr> <th>9</th> <td>BANGLADESH</td> <td>47</td> <td>1026</td> </tr> <tr> <th>10</th> <td>ZIMBABWE</td> <td>5</td> <td>53</td> </tr> </tbody> </table> <div data-role = "footer"> <h2>Footer</h2> </div> </body> </html>
Output
Let's carry out the following steps to see how the above code works −
Save the above html code as jqm_table_reflow.html file in your server root folder.
Open this HTML file as http://localhost/jqm_table_reflow.html and the following output will be displayed.
jquery_mobile_widgets.htm
Advertisements