mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Output: allow empty string data-attributes. See #923
This commit is contained in:
parent
18a97ed4d9
commit
7f9258f1e1
2
dist/js/widgets/widget-output.min.js
vendored
2
dist/js/widgets/widget-output.min.js
vendored
File diff suppressed because one or more lines are too long
@ -223,6 +223,7 @@
|
||||
|
||||
<h4>Changes</h4>
|
||||
<ul>
|
||||
<li>In <span class="version">v2.22.2</span>, the data-attribute used by the <code>output_dataAttrib</code> can now be an empty string.</li>
|
||||
<li>In <span class="version">v2.22.0</span>,
|
||||
<ul>
|
||||
<li>Added the BOM back to the UTF-8 csv downloadable file to support unicode characters in Excel.</li>
|
||||
@ -478,10 +479,11 @@ line,value1,value2,value3
|
||||
<td><a href="#" class="permalink">output_dataAttrib</a></td>
|
||||
<td><code>'data-name'</code></td>
|
||||
<td>
|
||||
This option allows you to override any table cell (<code>thead</code> or <code>tbody</code>) text with the contents of this data-attribute
|
||||
This option allows you to override any table cell (<code>thead</code> or <code>tbody</code>) text with the contents of this data-attribute (<span class="version updated">v2.22.2</span>)
|
||||
<div class="collapsible">
|
||||
<br>
|
||||
In the below example, the header text is obtained from this set data-attribute. If the data-attribute doesn't exist, then the header name is obtained from the actual header text.<br>
|
||||
<p>In the below example, the header text is obtained from this set data-attribute. If the data-attribute doesn't exist, then the header name is obtained from the actual header text.</p>
|
||||
<p>The data-attribute can be an empty string (<span class="version updated">v2.22.2</span>).</p>
|
||||
<pre class="prettyprint lang-html"><thead>
|
||||
<tr>
|
||||
<th>Rank</th>
|
||||
@ -493,8 +495,7 @@ line,value1,value2,value3
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead></pre>
|
||||
<br>
|
||||
Notice in this output that the "First" and "Last" columns match the contents of the <code>data-name</code> attribute and not the header text:
|
||||
<p>Notice in this output that the "First" and "Last" columns match the contents of the <code>data-name</code> attribute and not the header text:</p>
|
||||
<pre class="prettyprint lang-js">Rank,First,Last,Age,Total,Discount,Date</pre>
|
||||
<span class="label warning">* NOTE *</span> The core plugin uses the <code>data-text</code> attribute for text extraction. If you want to use the same data for both, make the data-attributes match!
|
||||
</div>
|
||||
|
@ -39,7 +39,7 @@ output = ts.output = {
|
||||
},
|
||||
|
||||
processRow: function(c, $rows, isHeader, isJSON) {
|
||||
var $this, row, col, rowlen, collen, txt,
|
||||
var $this, row, col, rowlen, collen, txt, attr,
|
||||
wo = c.widgetOptions,
|
||||
tmpRow = [],
|
||||
dupe = wo.output_duplicateSpans,
|
||||
@ -62,7 +62,9 @@ output = ts.output = {
|
||||
// process colspans
|
||||
if ($this.filter('[colspan]').length) {
|
||||
collen = parseInt( $this.attr('colspan'), 10) - 1;
|
||||
txt = output.formatData( wo, $this.attr(wo.output_dataAttrib) || $this.html(), isHeader );
|
||||
attr = $this.attr(wo.output_dataAttrib);
|
||||
// allow data-attribute to be an empty string
|
||||
txt = output.formatData( wo, typeof attr !== 'undefined' ? attr : $this.html(), isHeader );
|
||||
for (col = 1; col <= collen; col++) {
|
||||
// if we're processing the header & making JSON, the header names need to be unique
|
||||
if ($this.filter('[rowspan]').length) {
|
||||
|
Loading…
Reference in New Issue
Block a user