mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-04 23:53:15 +02:00
initial commit
This commit is contained in:
parent
fedf365400
commit
42fb664228
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tablefilter",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "A Javascript library making HTML tables filterable and a bit more",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
|
@ -51,7 +51,7 @@
|
|||
"string-replace-webpack-plugin": "^0.0.3",
|
||||
"sugar-date": "2.0.0",
|
||||
"webpack": "^1.13.2",
|
||||
"webpack-dev-server": "^1.16.1"
|
||||
"webpack-dev-server": "^1.16.2"
|
||||
},
|
||||
"dependencies": {},
|
||||
"bugs": {
|
||||
|
|
|
@ -17,6 +17,20 @@
|
|||
<td id="sum2"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Min:</td>
|
||||
<td></td>
|
||||
<td id="min1"></td>
|
||||
<td id="min2"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max:</td>
|
||||
<td></td>
|
||||
<td id="max1"></td>
|
||||
<td id="max2"></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<tr>
|
||||
|
|
|
@ -5,16 +5,44 @@ var totRowIndex = table.getElementsByTagName('tr').length;
|
|||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
rows_always_visible: [totRowIndex],
|
||||
rows_always_visible: [
|
||||
totRowIndex-2,
|
||||
totRowIndex-1,
|
||||
totRowIndex,
|
||||
],
|
||||
extensions: [{
|
||||
name: 'colOps',
|
||||
id: ['sum1', 'sum2'],
|
||||
col: [2, 3],
|
||||
operation: ['sum', 'mean'],
|
||||
write_method: ['innerhtml', 'innerhtml'],
|
||||
exclude_row: [totRowIndex],
|
||||
id: [
|
||||
'sum1', 'sum2',
|
||||
'min1', 'min2',
|
||||
'max1', 'max2'
|
||||
],
|
||||
col: [
|
||||
2, 3,
|
||||
2, 3,
|
||||
2, 3
|
||||
],
|
||||
operation: [
|
||||
'sum', 'mean',
|
||||
'min', 'min',
|
||||
'max', 'max'
|
||||
],
|
||||
write_method: [
|
||||
'innerhtml', 'innerhtml',
|
||||
'innerhtml', 'innerhtml',
|
||||
'innerhtml', 'innerhtml'
|
||||
],
|
||||
exclude_row: [
|
||||
totRowIndex-2,
|
||||
totRowIndex-1,
|
||||
totRowIndex
|
||||
],
|
||||
decimal_precision: [0, 2],
|
||||
tot_row_index: [totRowIndex, totRowIndex]
|
||||
tot_row_index: [
|
||||
totRowIndex-2, totRowIndex-2,
|
||||
totRowIndex-1, totRowIndex-1,
|
||||
totRowIndex, totRowIndex
|
||||
]
|
||||
}]
|
||||
});
|
||||
tf.init();
|
||||
|
@ -25,6 +53,8 @@ test('Column operations', function() {
|
|||
deepEqual(typeof colOps, 'object', 'ColOps instanciated');
|
||||
equal(id('sum1').innerHTML, 9911, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 1.69, 'Mean result');
|
||||
equal(id('min1').innerHTML, 286.00, 'Min result');
|
||||
equal(id('min2').innerHTML, 0.60, 'Min result');
|
||||
});
|
||||
|
||||
module('Behaviour checks');
|
||||
|
@ -33,38 +63,40 @@ test('Column operations after filtering', function() {
|
|||
tf.filter();
|
||||
equal(id('sum1').innerHTML, 3552, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 1.15, 'Mean result');
|
||||
equal(id('min1').innerHTML, 286.00, 'Min result');
|
||||
equal(id('min2').innerHTML, 0.60, 'Min result');
|
||||
tf.clearFilters();
|
||||
});
|
||||
|
||||
module('Behaviour checks with grid layout');
|
||||
test('Column operations', function() {
|
||||
tf.destroy();
|
||||
tf = null;
|
||||
totRowIndex = totRowIndex-2;
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
grid_layout: true,
|
||||
rows_always_visible: [totRowIndex],
|
||||
extensions: [{
|
||||
name: 'colOps',
|
||||
id: ['sum1', 'sum2'],
|
||||
col: [2, 3],
|
||||
operation: ['sum', 'mean'],
|
||||
write_method: ['innerhtml', 'innerhtml'],
|
||||
exclude_row: [totRowIndex],
|
||||
decimal_precision: [0, 2],
|
||||
tot_row_index: [totRowIndex, totRowIndex]
|
||||
}]
|
||||
});
|
||||
tf.init();
|
||||
// module('Behaviour checks with grid layout');
|
||||
// test('Column operations', function() {
|
||||
// tf.destroy();
|
||||
// tf = null;
|
||||
// totRowIndex = totRowIndex-2;
|
||||
// tf = new TableFilter('demo', {
|
||||
// base_path: '../dist/tablefilter/',
|
||||
// grid_layout: true,
|
||||
// rows_always_visible: [totRowIndex],
|
||||
// extensions: [{
|
||||
// name: 'colOps',
|
||||
// id: ['sum1', 'sum2'],
|
||||
// col: [2, 3],
|
||||
// operation: ['sum', 'mean'],
|
||||
// write_method: ['innerhtml', 'innerhtml'],
|
||||
// exclude_row: [totRowIndex],
|
||||
// decimal_precision: [0, 2],
|
||||
// tot_row_index: [totRowIndex, totRowIndex]
|
||||
// }]
|
||||
// });
|
||||
// tf.init();
|
||||
|
||||
equal(id('sum1').innerHTML, 9911, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 1.69, 'Mean result');
|
||||
// equal(id('sum1').innerHTML, 9911, 'Sum result');
|
||||
// equal(id('sum2').innerHTML, 1.69, 'Mean result');
|
||||
|
||||
tf.setFilterValue(2, '>1000');
|
||||
tf.filter();
|
||||
equal(id('sum1').innerHTML, 7771, 'Sum result');
|
||||
equal(id('sum2').innerHTML, 2.16, 'Mean result');
|
||||
// tf.setFilterValue(2, '>1000');
|
||||
// tf.filter();
|
||||
// equal(id('sum1').innerHTML, 7771, 'Sum result');
|
||||
// equal(id('sum2').innerHTML, 2.16, 'Mean result');
|
||||
|
||||
tf.destroy();
|
||||
});
|
||||
// tf.destroy();
|
||||
// });
|
||||
|
|
Loading…
Reference in a new issue