1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-06-08 00:42:28 +02:00

Updated 3.2 Column operations (markdown)

koalyptus 2015-06-13 14:20:06 +10:00
parent d926196b72
commit 2b55f8b100

@ -1,3 +1,199 @@
<p>To get the <code>colOps</code> extension instance:</p>
<pre>var sort = myTF.getExtension('colOps');</pre>
<pre>var colOps = myTF.getExtension('colOps');</pre>
<table>
<thead>
<tr>
<th>Property</th>
<th>Type</th>
<th>Description</th>
<th>Remarks</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<th>name</th>
<td>string</td>
<td><p>name of the extension, it should match the name of the directory and of the file, in this case 'colOps'.</p>
this extension can perform the following calculations on a specified column:
<ul>
<li>sum</li>
<li>mean</li>
<li>median</li>
<li>min</li>
<li>max</li>
<li>lower quartile</li>
<li>upper quartile</li>
</ul>
</td>
<td>
Special credit to Nuovella Williams for optimising the calculations and adding the "median", "lower quartile" and "upper quartile" calculations.
</td>
<td><code>var tfConfig = { extensions: [{ name: 'colOps' }] };</code></td>
</tr>
<tr>
<th>id</th>
<td>array</td>
<td>
list of the ids of elements displaying the calculation results.
</td>
<td></td>
<td><pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean']
}]
};</pre>
</td>
</tr>
<tr>
<th>col</th>
<td>array</td>
<td>collection of column indexes on which calculations will be performed.</td>
<td></td>
<td>
<pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean'],
col: [2, 4]
}]
};</pre>
</td>
</tr>
<tr>
<th>operation</th>
<td>array</td>
<td>list of the type of calculation per column, possible values: 'sum', 'mean', 'min', 'max', 'median', 'q1', 'q3'</td>
<td></td>
<td>
<pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean'],
col: [2, 4],
operation: ['sum', 'mean']
}]
};</pre>
</td>
</tr>
<tr>
<th>write_method</th>
<td>array</td>
<td>list instructing the extension how to write the calculation result, possible values: 'innerHTML', 'setValue', 'createTextNode' (default - 'innerHTML')</td>
<td></td>
<td>
<pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean'],
col: [2, 4],
operation: ['sum', 'mean'],
write_method: ['innerHTML', 'setValue']
}]
};</pre>
</td>
</tr>
<tr>
<th>exclude_row</th>
<td>array</td>
<td>collection of row indexes from be excluded from the calculation</td>
<td></td>
<td>
<pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean'],
col: [2, 4],
operation: ['sum', 'mean'],
write_method: ['innerHTML', 'setValue']
exclude_row: [7, 18]
}]
};
</pre>
</td>
</tr>
<tr>
<th>decimal_precision</th>
<td>function</td>
<td>the decimal precision to be applied on the calculation result per column</td>
<td></td>
<td>
<pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean'],
col: [2, 4],
operation: ['sum', 'mean'],
write_method: ['innerHTML', 'setValue']
exclude_row: [7, 18],
decimal_precision: [2, 1]
}]
};
</pre>
</td>
</tr>
<tr>
<th>on_before_operation</th>
<td>function</td>
<td>callback fired before the column calculations are performed (default - null)</td>
<td><p>1 parameter:</p>
<ul>
<li>o is the current TableFilter instance</li>
</ul></td>
<td>
<pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean'],
col: [2, 4],
operation: ['sum', 'mean'],
write_method: ['innerHTML', 'setValue']
exclude_row: [7, 18],
decimal_precision: [2, 1],
on_before_operation: function(o){
console.log(o.getExtension('colOps'));
}
}]
};
</pre>
</td>
</tr>
<tr>
<th>on_after_operation</th>
<td>function</td>
<td>callback fired after the column calculations are performed (default - null)</td>
<td><p>1 parameter:</p>
<ul>
<li>o is the current TableFilter instance</li>
</ul></td>
<td>
<pre>
var tfConfig = {
extensions: [{
name: 'colOps',
id: ['col2Total', 'col4Mean'],
col: [2, 4],
operation: ['sum', 'mean'],
write_method: ['innerHTML', 'setValue']
exclude_row: [7, 18],
decimal_precision: [2, 1],
on_after_operation: function(o){
console.log(o.getExtension('colOps'));
}
}]
};
</pre>
</td>
</tr>
</tbody>
</table>