put 'input' in every cell and get their content, **including other pages**
put 'input' in every cell and get their content, **including other pages**
Hello,
I have a DataTables with 20 pages and, using 'render' function, I can add an input box into each cell of a given column. That's ok. In 'column' part of DataTables initialization, I have the following :
{name: 'colname', data: null,
render:function ( data, type, row ) {
return "<input type='text' class='form-control' value='' name='inputname'>";
}
},
Now, imagine that the user puts some text into those input on different pages, and I would like to grab all input values when the user clicks on a button. In the 'on('click' ...' event catcher, I have that :
$( "input[name='inputname']" ).each(function( index, element ) {
console.log( index, element );
});
The problem is that it only gets the displayed elements but it does not log ALL the elements in the DataTables, including those which are displayed on a different page...
How can I extract ALL the values of the 'inputname' input elements ??
Thanks,
T.
Answers
I think you can do something like this:
Where
table
is an instance of the Datatables API. It usesrows().nodes()
and.-to$()` to allow jQuery find() to be used.
Kevin
YES ! Thank you very much ! That's perfect :-)