Displaying all rows by default
Displaying all rows by default
mmcdougall
Posts: 1Questions: 0Answers: 0
Hi there,
Please excuse my ignorance, I am completely new to Datatables and most forms of JS.
Basically what I am trying to do is display all rows on the table by default. The datatables js is completely untouched in the body, but I have added the following code to the bottom. The last bit is where I wanted to display all rows.
[code]
$('#homeinv').dataTable(
{
"bSort" : false
} );
$('#products').dataTable(
{
"bSort" : false
} );
$(document).ready(function() {
$('#invmain').dataTable( {
"aoColumns": [
{ "asSorting": [ "desc" ] },
null,
null,
null,
null,
{ "bSortable": false }
]
} );
} );
$(document).ready(function() {
$('#invmain').dataTable( {
"iDisplayLength": "All",
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
} );
} );
[/code]
Basically what happens is whenever I open the page, I get the following message from the browser:
[quote]
Datatables warning (table id = 'invmain'): Cannot reinitialise DataTable.
To retrieve the DataTables object for this table, please pass either no arguments to the dataTable() function, or set bRetrieve to true.
[/quote]
Any help would be greatly appreciated!
Thanks,
Matthew
Please excuse my ignorance, I am completely new to Datatables and most forms of JS.
Basically what I am trying to do is display all rows on the table by default. The datatables js is completely untouched in the body, but I have added the following code to the bottom. The last bit is where I wanted to display all rows.
[code]
$('#homeinv').dataTable(
{
"bSort" : false
} );
$('#products').dataTable(
{
"bSort" : false
} );
$(document).ready(function() {
$('#invmain').dataTable( {
"aoColumns": [
{ "asSorting": [ "desc" ] },
null,
null,
null,
null,
{ "bSortable": false }
]
} );
} );
$(document).ready(function() {
$('#invmain').dataTable( {
"iDisplayLength": "All",
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]]
} );
} );
[/code]
Basically what happens is whenever I open the page, I get the following message from the browser:
[quote]
Datatables warning (table id = 'invmain'): Cannot reinitialise DataTable.
To retrieve the DataTables object for this table, please pass either no arguments to the dataTable() function, or set bRetrieve to true.
[/quote]
Any help would be greatly appreciated!
Thanks,
Matthew
This discussion has been closed.
Replies
Once initialized, I don't believe you can add any initialization settings (unless you also pass in bDestroy which discards the existing DataTable and rebuilds one).
[code]
$(document).ready(function() {
$('#invmain').dataTable( {
"iDisplayLength": "All",
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
"aoColumns": [
{ "asSorting": [ "desc" ] },
null,
null,
null,
null,
{ "bSortable": false }
]
} );
} );[/code]
also, can you pass "All" to iDisplayLength"? It expects an integer. perhaps -1 will display all, or set it to a really large integer like 99999. Couldn't find anything in the reference about this.