mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Added group-separator option
This commit is contained in:
parent
818b82dcae
commit
8d37bdecda
@ -137,6 +137,7 @@
|
||||
<ul>
|
||||
<li>This widget will <strong>only work</strong> in tablesorter version 2.8+ and jQuery version 1.7+.</li>
|
||||
<li>Please do not use this widget in very large tables (it might be really slow) <del>or when your table includes multiple tbodies</del>.</li>
|
||||
<li>In <span class="version">v2.12.1</span>, added <code>group_separator</code> option & <code>group-separator-#</code> header class name.</li>
|
||||
<li>In <span class="version">v2.12</span>, added <code>group_callback</code> & <code>group_complete</code> options. See options section below for details.</li>
|
||||
<li>In <span class="version">v2.11</span>:
|
||||
<ul>
|
||||
@ -158,13 +159,15 @@
|
||||
<li><code>group_collapsible</code> (<code>true</code>) - when <code>true</code>, the group headers become clickable and collapse the rows below it.</li>
|
||||
<li><code>group_collapsed</code> (<code>false</code>) - when <code>true</code> and <code>group_collapsible</code> is also <code>true</code>, all groups will start collapsed (<span class="version">v2.11</span>).</li>
|
||||
<li><code>group_count</code> (<code>" ({num})"</code>) - allows you to add custom formatting, or remove, the group count within the group header. Set it to <code>false</code> or an empty string to remove the count.</li>
|
||||
<li>group date/time options - Name arrays included so that the language of the date groups can be modified easily. Defaults (English):
|
||||
<li><code>group_callback</code> (<code>null</code>) - use this function to further modify the group header to include more information (i.e. group totals). Parameters include (<code>$cell, $rows, column, table</code>). See the example below for more details <span class="version">v2.12</span>.
|
||||
<ul>
|
||||
<li><code>group_months</code> (<code>[ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]</code>) - Month names.</li>
|
||||
<li><code>group_week</code> (<code>[ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]</code>) - Named days of the week.</li>
|
||||
<li><code>group_time</code> (<code>[ "AM", "PM" ]</code>) - Time of day.</li>
|
||||
<li><code>$cell</code> - current group header table cell (jQuery object).</li>
|
||||
<li><code>$rows</code> - current group rows (jQuery object).</li>
|
||||
<li><code>column</code> - current table column being grouped (zero-based index).</li>
|
||||
<li><code>table</code> - current table (DOM).</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>group_complete</code> (<code>"groupingComplete"</code>) - event triggered on the table when the grouping widget has finished work <span class="version">v2.12</span>.</li>
|
||||
<li><code>group_formatter</code> (<code>null</code>) - use this function to modify the group header text before it gets applied. It provides various parameters (<code>txt, col, table, c, wo</code>) to make it work for any of the table columns and data. See the comments in the example below for more details.
|
||||
<ul>
|
||||
<li><code>txt</code> - current text of the group header.</li>
|
||||
@ -174,16 +177,14 @@
|
||||
<li><code>wo</code> - table widget options from <code>table.config.widgetOptions</code>.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>group_callback</code> (<code>null</code>) - use this function to further modify the group header to include more information (i.e. group totals). Parameters include (<code>$cell, $rows, column, table</code>). See the example below for more details <span clss="version">v2.12</span>.
|
||||
<li><code>group_separator</code> (<code>"-"</code>) - when the <code>group-separator</code> class name is added, it uses the setting from this option to split the table cell content for grouping <span class="version">v2.12.1</span>.</li>
|
||||
<li>group date/time options - Name arrays included so that the language of the date groups can be modified easily. Defaults (English):
|
||||
<ul>
|
||||
<li><code>$cell</code> - current group header table cell (jQuery object).</li>
|
||||
<li><code>$rows</code> - current group rows (jQuery object).</li>
|
||||
<li><code>column</code> - current table column being grouped (zero-based index).</li>
|
||||
<li><code>table</code> - current table (DOM).</li>
|
||||
<li><code>group_months</code> (<code>[ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]</code>) - Month names.</li>
|
||||
<li><code>group_week</code> (<code>[ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]</code>) - Named days of the week.</li>
|
||||
<li><code>group_time</code> (<code>[ "AM", "PM" ]</code>) - Time of day.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</li>
|
||||
<li><code>group_complete</code> (<code>"groupingComplete"</code>) - event triggered on the table when the grouping widget has finished work <span clss="version">v2.12</span>.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -193,6 +194,8 @@
|
||||
<ul>
|
||||
<li><code>"group-word"</code> (same as <code>"group-word-1"</code>) - group the rows using the first word it finds in the column's parsed data.</li>
|
||||
<li><code>"group-word-n"</code> (<code>"n"</code> can be any number) - group the rows using the nth word in the column<span class="remark">*</span>.</li>
|
||||
<li><code>"group-separator"</code> (same as <code>"group-separator-1"</code>) - group the rows using the text between the start and first separator that it finds in the column's parsed data (<span class="version">v2.12.1</span>).</li>
|
||||
<li><code>"group-separator-n"</code> (<code>"n"</code> can be any number) - group the rows using the nth separated group in the column (<span class="version">v2.12.1</span>)<span class="remark">*</span>.</li>
|
||||
<li><code>"group-letter"</code> (same as <code>"group-letter-1"</code>) - group the rows using the first letter it finds in the column's parsed data.</li>
|
||||
<li><code>"group-letter-n"</code> (<code>"n"</code> can be any number) - group the rows using letters 1 through n (if n = 2, then it's the first 2 letters) in the column's parsed data.</li>
|
||||
<li><code>"group-number"</code> (same as <code>"group-number-1"</code>) - group the rows by the number it finds in the column (step of one).</li>
|
||||
|
@ -24,6 +24,11 @@ ts.grouping = {
|
||||
return w && w.length >= num ? w[num - 1] : txt || '';
|
||||
}
|
||||
},
|
||||
separator : function(c, $col, txt, num){
|
||||
var wo = c.widgetOptions,
|
||||
w = (txt + '').split(wo.group_separator);
|
||||
return $.trim(w && num > 0 && w.length >= num ? w[(num || 1) - 1] : '');
|
||||
},
|
||||
word : function(c, $col, txt, num){
|
||||
var w = (txt + ' ').match(/\w+/g);
|
||||
return w && w.length >= num ? w[num - 1] : txt || '';
|
||||
@ -53,13 +58,15 @@ ts.addWidget({
|
||||
group_collapsible : true, // make the group header clickable and collapse the rows below it.
|
||||
group_collapsed : false, // start with all groups collapsed
|
||||
group_count : ' ({num})', // if not false, the "{num}" string is replaced with the number of rows in the group
|
||||
group_separator : '-', // group name separator; used when group-separator-# class is used.
|
||||
group_formatter : null, // function(txt, col, table, c, wo) { return txt; }
|
||||
group_callback : null, // function($cell, $rows, column, table){}, callback allowing modification of the group header labels
|
||||
group_complete : 'groupingComplete', // event triggered on the table when the grouping widget has finished work
|
||||
|
||||
// change these default date names based on your language preferences
|
||||
group_months : [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
|
||||
group_week : [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ],
|
||||
group_time : [ 'AM', 'PM' ],
|
||||
group_formatter : null, // function(txt, col, table, c, wo) { return txt; }
|
||||
group_callback : null, // function($cell, $rows, column, table){}, callback allowing modification of the group header labels
|
||||
group_complete : 'groupingComplete' // event triggered on the table when the grouping widget has finished work
|
||||
group_time : [ 'AM', 'PM' ]
|
||||
},
|
||||
init: function(table, thisWidget, c, wo){
|
||||
if (wo.group_collapsible) {
|
||||
|
Loading…
Reference in New Issue
Block a user