Table Tools select_all seems to ignore filter criteria
Table Tools select_all seems to ignore filter criteria
mdiessner
Posts: 34Questions: 0Answers: 0
Hi Allan,
This refers to pre-defined buttons:
http://datatables.net/release-datatables/extras/TableTools/select_multi.html
When using select_all in aButtons, it seems that this default button ignores filter a criterion.
Example: If one filters in the search field browser value = "1.8" and then presses aButtons:select_all, and then "un-filters" by deleting the "1.8" from the search filter, all records are selected instead of only those that were selected in the previous step.
In addition, the following function does not work e.g. a row_selected_counter is not increased/decreased by using the aButtons:select_all and aButtons:select_none pre-defined buttons:
[code]
"fnRowSelected":
function () {
row_select_counter++;
},
"fnRowDeselected":
function () {
row_select_counter = row_select_counter-1;
},
[/code]
It would be nice to have the pre-defined buttons being extended with that functionality, and maybe also the core provide a status counter of the number of selected rows.
Thanks,
Rgds
Martin
This refers to pre-defined buttons:
http://datatables.net/release-datatables/extras/TableTools/select_multi.html
When using select_all in aButtons, it seems that this default button ignores filter a criterion.
Example: If one filters in the search field browser value = "1.8" and then presses aButtons:select_all, and then "un-filters" by deleting the "1.8" from the search filter, all records are selected instead of only those that were selected in the previous step.
In addition, the following function does not work e.g. a row_selected_counter is not increased/decreased by using the aButtons:select_all and aButtons:select_none pre-defined buttons:
[code]
"fnRowSelected":
function () {
row_select_counter++;
},
"fnRowDeselected":
function () {
row_select_counter = row_select_counter-1;
},
[/code]
It would be nice to have the pre-defined buttons being extended with that functionality, and maybe also the core provide a status counter of the number of selected rows.
Thanks,
Rgds
Martin
This discussion has been closed.
Replies
[code]
var oTT = TableTools.fnGetInstance('table_main');
alert('Number of selected rows = '+oTT.fnGetSelected().length);
[/code]
Workaround - maybe not the fastest but does the trick!
[code]
"aButtons": [
{
"sExtends": "select",
"sButtonText": "Select Filtered",
"fnClick": function (nButton, oConfig, oFlash) {
var oTT = TableTools.fnGetInstance('table_main');
oTT.fnSelectAll(true); //True = Select only filtered rows (true). Optional - default false.
}
},
]
[/code]
Works nicely - so would be nice to have a pre-defined button called "select_filtered" which does exactly that ;-)
Thanks for posting your solution - I'll look at wrapping up these two plug-ins.
Allan
Need a challenge?
"select_inverse_filtered" - select all records that were not filtered.
I am building a custom accounting system (or part thereof) and have to clean up a lot of data....
[code]
{
"sExtends": "text",
"sButtonText": "Select filtered out",
"fnClick": function ( button, config ) {
var filterSet = table.$('tr', {filter:'applied'});
return table.$('tr').map( function (index, el) {
return $.inArray( el, filterSet ) === -1 ? el : null;
} );
}
}
[/code]
It simply gets the currently filtered element set, the full set and calculates the difference. Not particularly optimal due to the inner loop, but it should do the job nicely.
Allan