Move Data from one Datatable to another : ReferenceError: fnGetSelected is not defined
Move Data from one Datatable to another : ReferenceError: fnGetSelected is not defined
pracede2005
Posts: 10Questions: 0Answers: 0
I have two datatatles. The first retrieve data form the server. In this datatable i have a check box column and a button. I want to move selected (checked) rows from this datatable to the second when i click on the button. I am getting the error ReferenceError: fnGetSelected is not defined. Someone could help to write the function fnGetSelected ?
Here my code
[code]
$(document).ready(function() {
oTable = $('#parameterList').dataTable( {
"bLengthChange": false,
"sPaginationType": "full_numbers",
"bFilter": true,
"bProcessing": true,
"sAjaxSource":'/OCC/json/LoadPerimetre.action?'+params, // URL d'appel pour recuperer les datas json
"aoColumns": [ // definition de l'ordre et la largeur des colonnes
{ "mData": "nomGroupe","sWidth": "20%" },
{ "mData": "nomSousGroupe1","sWidth": "10%" },
{ "mData": "nomEntreprise","sWidth": "40%" },
{ "mData": "siren","sWidth": "25%" },
{ "mData": "selection","sWidth": "5%" }
]
} );
nTable = $('#parameterFinalList').dataTable( {
"bLengthChange": false,
"sPaginationType": "full_numbers",
"bFilter": false,
"bProcessing": true, // avtive le traitement JSON
"aoColumns": [ // definition de l'ordre et la largeur des colonnes
{ "mData": "nomGroupe","sWidth": "20%" },
{ "mData": "nomSousGroupe1","sWidth": "10%" },
{ "mData": "nomEntreprise","sWidth": "40%" },
{ "mData": "siren","sWidth": "25%" },
{ "mData": "selection","sWidth": "5%" }
]
} );
$('#selectAll').click( function() {
$('input', oTable.fnGetNodes()).attr('checked',this.checked);
} );
// Add to DEST and remove from Source
$('#finalChoices').click( function() {
var selected_entries = fnGetSelected(oTable);
var selected_Len = selected_entries.length;
var i = 0;
for(i=0; i
Here my code
[code]
$(document).ready(function() {
oTable = $('#parameterList').dataTable( {
"bLengthChange": false,
"sPaginationType": "full_numbers",
"bFilter": true,
"bProcessing": true,
"sAjaxSource":'/OCC/json/LoadPerimetre.action?'+params, // URL d'appel pour recuperer les datas json
"aoColumns": [ // definition de l'ordre et la largeur des colonnes
{ "mData": "nomGroupe","sWidth": "20%" },
{ "mData": "nomSousGroupe1","sWidth": "10%" },
{ "mData": "nomEntreprise","sWidth": "40%" },
{ "mData": "siren","sWidth": "25%" },
{ "mData": "selection","sWidth": "5%" }
]
} );
nTable = $('#parameterFinalList').dataTable( {
"bLengthChange": false,
"sPaginationType": "full_numbers",
"bFilter": false,
"bProcessing": true, // avtive le traitement JSON
"aoColumns": [ // definition de l'ordre et la largeur des colonnes
{ "mData": "nomGroupe","sWidth": "20%" },
{ "mData": "nomSousGroupe1","sWidth": "10%" },
{ "mData": "nomEntreprise","sWidth": "40%" },
{ "mData": "siren","sWidth": "25%" },
{ "mData": "selection","sWidth": "5%" }
]
} );
$('#selectAll').click( function() {
$('input', oTable.fnGetNodes()).attr('checked',this.checked);
} );
// Add to DEST and remove from Source
$('#finalChoices').click( function() {
var selected_entries = fnGetSelected(oTable);
var selected_Len = selected_entries.length;
var i = 0;
for(i=0; i
This discussion has been closed.
Replies
[code]
function fnGetSelected (oTable) {
return $('input:checked', oTable.fnGetNodes()).closest('tr');
}
[/code]
[code]
function fnGetSelected(oTable) {
return $('input:checked', oTable.fnGetNodes()).closest('tr');
}
$('#finalChoices').click( function() {
var rows = fnGetSelected(oTable),
data = oTable._(rows);
//add all data to destination table
destTable.fnAddData(data);
//iterate over rows and remove from original table (note false on redraw)
rows.each(function(i, el) {
oTable.fnDelete(el, null, false);
});
//only render table once (saves a lot of rendering cycles)
oTable.fnDraw();
});
[/code]