-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathtable.xml
132 lines (119 loc) · 7.24 KB
/
table.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="../entries2html.xsl" ?>
<entry name="table" namespace="fn" type="widget" widgetnamespace="mobile" event-prefix="table" init-selector=":jqmData(role='table')">
<title>Table Widget</title>
<desc>Creates a responsive table</desc>
<longdesc>
<h2>Responsive tables</h2>
<p>One of the biggest challenges in responsive web design (RWD) is presenting tabular data. Large tables with lots of columns don't fit on smaller screens and there isn't a simple way to re-format the table content with CSS and media queries for an acceptable presentation. To address this, the framework offers two different options for presenting tables responsively. Each has benefits and tradeoffs, the right choice will depend on the data being presented.</p>
<p><a href="table-reflow">Reflow mode</a> - Re-formats the table columns at narrow widths so each row of data is presented as a formatted block of label/data pairs. This is ideal for tables with product or contact information with more complex or lengthy data formatting that doesn't need comparison across rows of data.</p>
<p><a href="table-columntoggle">Column toggle mode</a> - Selectively hides columns at narrower widths as a sensible default but also offers a menu to let users manually control which columns they want to see. This mode is better for financial data tables that have compact values and need to maintain comparisons across columns and rows of data. It can also be used for building things like product comparison tables.</p>
<p>The responsive table feature is built with a core table plugin (<code>table.js</code>) that initializes when the <code>data-role="table"</code> attribute is added to the markup. This plugin is very lightweight and adds <code>ui-table</code> class, parses the table headers and generates information on the columns of data, and fires a <code>tablecreate</code> event. Both the table modes, <a href="table-reflow">reflow</a> and <a href="table-columntoggle">column toggle</a>, are written as extensions to the table widget that hook in via the <code>create</code> event to add the additional behaviors that make the tables responsive. Reflow is the default mode so if the extension is present, it will be applied automatically if the <code>data-role="table"</code> attribute is on the table.</p>
<p>If only one mode is used on a project, the download builder tool can be used to package only the table plugin and the single extension to save code weight.</p>
<h3>General table markup guidelines</h3>
<p>Here is the basic table markup you should use for both table modes:</p>
<pre><code><![CDATA[
<table data-role="table" id="my-table" data-mode="reflow">
<thead>
<tr>
<th>Rank</th>
<th>Movie Title</th>
<th>Year</th>
<th><abbr title="Rotten Tomato Rating">Rating</abbr></th>
<th>Reviews</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<td><a href="foo.com" data-rel="external">Citizen Kane</a></td>
<td>1941</td>
<td>100%</td>
<td>74</td>
</tr>
</tbody>
</table>
]]></code></pre>
<p>Both table modes start with standard HTML table markup but there are some specific guidelines you must follow for the responsive table to work correctly: </p>
<ul class="bullet">
<li>Follow standard HTML table markup guidelines for proper semantics</li>
<li>Do not use <code>rowspan</code> or <code>colspan</code> in your tables, these aren't supported except for grouped headers (see below)</li>
<li>Adding <code>thead</code> and <code>tbody</code> elements are optional but provide improved semantics</li>
<li>Assign a unique <code>ID</code> to the table (required for the column toggle mode)</li>
<li>Add the <code>data-role="table"</code> to apply the responsive table plugin</li>
<li>The default table mode is <code>reflow</code>, add <code>data-mode="columntoggle"</code> change modes</li>
<li>The first row of the table must contain the table headers, be sure to use <code>TH</code> instead of <code>TD</code> tags</li>
<li>To display longer table header text in the column chooser or reflow labels, wrap the text in the <code>TH</code> with a <code>abbr</code> element and set the <code>title</code>. This string will be used in place.</li>
</ul>
<h3>Styling and theming tables</h3>
<p>The responsive table plugin is as minimally styled as possible to give you a clean slate for your designs. The plugin focuses primarily on the difficult scripting elements: generating the labels for the reflow table and creating the button and column chooser popup. Out of the box, the table just has a few basic style rules to add a bit of padding and set the vertical alignment of cells to be top left for visual consistency. </p>
<p>The table will adapt to whatever content block it sits on, but there isn't an explicit theming attribute for this widget. We did this because it's simple enough to add theme classes like <code>ui-body-a</code> to individual cells if a more heavily themed look is wanted.</p>
<h3>Row strokes and stripes</h3>
<p>The theme CSS contains a preset row strokes and alternating row stripes style which can be applied by adding <code>table-stroke</code> or <code>table-stripe</code> class to the <code>table</code> element.</p>
<strong>Note: the <code>table-stroke</code> and <code>table-stripe</code> classes are deprecated as of jQuery Mobile 1.4.0 and will be removed in 1.5.0. The demos contain an example how to apply these styles with custom CSS.</strong>
</longdesc>
<added>1.3</added>
<options>
<option name="classes" type="Object">
<default>{
"ui-table": ""
}</default>
<xi:include href="../includes/classes-option-desc.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/classes-option-example.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</option>
<xi:include href="../includes/widget-option-defaults.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/widget-option-disabled.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
<xi:include href="../includes/widget-option-initSelector.xml" xmlns:xi="http://www.w3.org/2003/XInclude"/>
</options>
<events>
<event name="create">
<desc>Triggered when a table is created
</desc>
<argument name="event" type="Event">
<desc></desc>
</argument>
<argument name="ui" type="Object">
<desc></desc>
</argument>
</event>
</events>
<methods>
<method name="rebuild">
<desc>Re-process the entire table to ensure it is displayed correctly.</desc>
</method>
</methods>
<example>
<height>350</height>
<desc>A basic example of a reponsive table.</desc>
<html><![CDATA[
<div data-role="page" id="page1">
<div data-role="header">
<h1>jQuery Mobile Example</h1>
</div>
<div role="main" class="ui-content">
<table data-role="table" id="my-table" data-mode="reflow">
<thead>
<tr>
<th>Rank</th>
<th>Movie Title</th>
<th>Year</th>
<th><abbr title="Rotten Tomato Rating">Rating</abbr></th>
<th>Reviews</th>
</tr>
</thead>
<tbody>
<tr>
<th>1</th>
<td><a href="foo.com" data-rel="external">Citizen Kane</a></td>
<td>1941</td>
<td>100%</td>
<td>74</td>
</tr>
</tbody>
</table>
</div>
</div>
]]></html>
</example>
<category slug="widgets"/>
</entry>