reflow
column toggle
data-role="table"
and "ui-responsive"
class on the <table>
element to create a table.
To make the responsive table to work properly, add the <thead>
and <tbody>
elements instead of rowspan or colspan.
Eg:
[html]
<table data-role="table" class="ui-responsive">[/html] data-mode="columntoggle"
to the following <table>
element.
Eg:
[html]
<table data-role="table" data-mode="columntoggle" class="ui-responsive ui-shadow" data-column-btn-text="Click here!" id="mytable">[/html]
To specify order in which column that should be shown or hidden,add data-priority attribute to <th>
and set a number between 1 (highest priority) to 6 (lowest priority).
[html]
<thead>
<tr>
<th data-priority="6">Employee ID</th>
<!--lowest priority -->
<th>Employee Name</th>
<!-- This will never be hidden since you are not setting any priority-->
<th data-priority="1">Employee Email-ID</th>
<!-- highest priority -->
<th data-priority="3">Employee Phone Number</th>
<th data-priority="4">Employee Country</th>
</tr>
</thead>
[/html]
In this JQuery Mobile, a button is added automatically at the top right corner of the table using which user can choose columns to display or hide in the table. To change text add data-column-btn-text="text” to the <table>.
Eg:
[html]
<table data-role="table" data-mode="columntoggle" class="ui-responsive ui-shadow" data-column-btn-text="Click here!" id="mytable">[/html] <th>
elements, add a bottom border and add background color to all even table rows.
[html]
<style>
#mytable th {
border-bottom: 2px solid #d6d6d6;
background: #00B2EE;
}
tr:nth-child(even) {
background: #e9e9e9;
}
</style>
[/html]