WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

jQuery Mobile Tables


Responsive Tables

Responsive structure is valuable when you need the substance of your versatile page to react to the client's gadget, for example, its screen measure and orientation.

With a straightforward class name, jQuery Mobile knows about the client's accessible screen estimate and naturally resizes itself to indicate content that is applicable for that specific user.

Responsive tables enable us to show a vast arrangement of forbidden information that will look appealing for the two mobiles and desktops.

There are two kinds of responsive tables: reflow and column toggle.


Reflow Table

The reflow mode positions the table information evenly until it achieves a base measure, at that point all lines are assembled together vertically.

Create a table, include the information role="table" and a class of "ui-responsive" on the <table> element:

Example

<table data-role="table" class="ui-responsive">
Try it yourself »


Column Toggle Table

The "column toggle" mode will shroud segments when there isn't sufficient width to show the data.

To make a section switch table, add the accompanying to the <table> element:

<table data-role="table" information mode="columntoggle" class="ui-responsive" id="myTable">

By default, jQuery Mobile will conceal sections from the correct side of the table. Nonetheless, you are permitted to indicate which section that ought to be covered up or appeared in a particular request. Add the information need credit to the table's header (<th>) and determine a number between 1 (most astounding need) to 6 (least priority):

<th>I will never be hidden</th>
<th data-priority="1">I am essential - I will presumably not be hidden</th>
<th data-priority="3">I am less essential - I could be hidden</th>
<th data-priority="5">I am not excessively vital - there is a decent chance that I will be hidden</th>

Put it all together and you have made a section switch table! Notice that the system naturally includes a catch in the upper right corner of the table. This lets the user to pick which segment to show in the table:

Example

<table data-role="table" information mode="columntoggle" class="ui-responsive" id="myTable">
  <thead>
    <tr>
      <th data-priority="6">CustomerID</th>
      <th>CustomerName</th>
      <th data-priority="1">ContactName</th>
      <th data-priority="2">Address</th>
      <th data-priority="3">City</th>
      <th data-priority="4">PostalCode</th>
      <th data-priority="5">Country</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>Alfreds Futterkiste</td>
      <td>Maria Anders</td>
      <td>Obere Str. 57</td>
      <td>Berlin</td>
      <td>12209</td>
      <td>Germany</td>
    </tr>
  </tbody>
</table>
Try it yourself »

To change the switch table catch content, utilize the information segment btn-content attribute:

Example

<table information role="table" information mode="columntoggle" class="ui-responsive" data-segment btn-text="Click me to cover up or show columns!" id="myTable">
Try it yourself »

Styling Tables

Use the "ui-shadow" class to add shadows to the table:

Add shadow

<table information role="table" information mode="columntoggle" class="ui-responsive ui-shadow" id="myTable">
Try it yourself »

For further table styling, use CSS:

Add a base outskirt to all table rows

<style>
tr {
    outskirt base: 1px strong #d6d6d6;
}
</style>
Try it yourself »

Add a base outskirt to all <th> components and a foundation shading to all even table rows

<style>
th {
    outskirt base: 1px strong #d6d6d6;
}

tr:nth-child(even) {
    foundation: #e9e9e9;
}
</style>
Try it yourself »