How to display table data in stripes and strokes format in jQuery Mobile ?
In this article, we will learn how to display table data in stripes and strokes format. To display table data in stripes and strokes format, set the data-role=”table” and data-mode=”reflow” using the classes table-stripe, table-stroke, ui-responsive.
Reflow mode: The ui-responsive class is used to create responsive tables. The data in responsive tables presented are in two modes, reflow and column toggle. In this session, we will focus on reflow mode.
Reflow mode reformats the table columns at narrow widths such that each row of the table is displayed as a block of data pairs. The tables information with more complex or lengthy data formatting that doesn’t need comparison among rows of data can be presented in reflow mode.
<table data-role=”table” data-mode=”reflow” class=”ui-responsive”>
The classes table-stripe, table-stroke will give the rows of a table zebra stripes effect. The alternating rows will be in two different shades.
<link rel=”stylesheet” href=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css”>
- Firstly, add the above jQuery and jQuery Mobile CDN links to the script or download them to your local machine.
- Create a table tag and set the data-role attribute to “table” and data-mode attribute to “reflow”.
- Set the classes of table tag to table-stripe, table-stroke, ui-responsive.
- The ui-responsive class will make the table responsive.
- The table-stripe and table-stroke give the zebra stripe effect to the table.
- Create the column names using the thead tag and the th tag.
- The data of the table is added using the body tag.
- The rows are created using the tr tag.
Please Login to comment...