New Button Invert Selection Code
New Button Invert Selection Code
shazada
Posts: 1Questions: 0Answers: 0
Hi,
I didn't see any topic with the inverted selection button, hence I took my time to write it.
The following works for my need and hopefully someone can add it to the stock code, because what's great can be greater ;).
[code]
var oTable = $('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sRowSelect": "multi",
"aButtons": ["select_all", "select_none",
{
"sExtends": "text",
"sButtonText": "Invert Selection",
"fnClick": function(nButton, oConfig) {
var selected = [];
var unselected = [];
var data = this.s.dt.aoData;
for (var i = 0; i < data.length; i++) {
if (data[i]._DTTT_selected)
selected.push(data[i]);
else
unselected.push(data[i]);
}
this._fnRowDeselect(selected);
this._fnRowSelect(unselected);
}
}]
}
});
[/code]
I didn't see any topic with the inverted selection button, hence I took my time to write it.
The following works for my need and hopefully someone can add it to the stock code, because what's great can be greater ;).
[code]
var oTable = $('#example').dataTable({
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sRowSelect": "multi",
"aButtons": ["select_all", "select_none",
{
"sExtends": "text",
"sButtonText": "Invert Selection",
"fnClick": function(nButton, oConfig) {
var selected = [];
var unselected = [];
var data = this.s.dt.aoData;
for (var i = 0; i < data.length; i++) {
if (data[i]._DTTT_selected)
selected.push(data[i]);
else
unselected.push(data[i]);
}
this._fnRowDeselect(selected);
this._fnRowSelect(unselected);
}
}]
}
});
[/code]
This discussion has been closed.
Replies
Regards,
Allan