Custom display length problem
Custom display length problem
virgil
Posts: 12Questions: 0Answers: 0
Hi,
I'm trying to use my own custom display length changer, and I got to this:
[code]
$('#change_iDisplayLength').click( function() {
if ($('#iDisplayLength').val() != display_length) {
display_length = $('#iDisplayLength').val();
var oSettings = oTable.fnSettings();
oSettings._iDisplayLength = $('#iDisplayLength').val();
oTable.fnPageChange("first");
//oTable.fnDraw();
}
});
[/code]
Now this work great if I get my data dynamically but not if I have my data already in the table from the beginning
For example, I have 16 entries that I return from the start and 10 entries per page set by default, now if I change to 5 entries per page it takes me to the first page and I have 5 entries on it, from 1 to 5, but then on the second page I have entries from 6 to 16, on third from 10 to 16 and on fourth entry 16 again. I don't get what I'm doing wrong, especially that this works great if I get the entries dynamically for every page. I tried calling fnDraw but that didn't help either.
Any ideea about what I might be doing wrong?
Thanks,
Virgil
I'm trying to use my own custom display length changer, and I got to this:
[code]
$('#change_iDisplayLength').click( function() {
if ($('#iDisplayLength').val() != display_length) {
display_length = $('#iDisplayLength').val();
var oSettings = oTable.fnSettings();
oSettings._iDisplayLength = $('#iDisplayLength').val();
oTable.fnPageChange("first");
//oTable.fnDraw();
}
});
[/code]
Now this work great if I get my data dynamically but not if I have my data already in the table from the beginning
For example, I have 16 entries that I return from the start and 10 entries per page set by default, now if I change to 5 entries per page it takes me to the first page and I have 5 entries on it, from 1 to 5, but then on the second page I have entries from 6 to 16, on third from 10 to 16 and on fourth entry 16 again. I don't get what I'm doing wrong, especially that this works great if I get the entries dynamically for every page. I tried calling fnDraw but that didn't help either.
Any ideea about what I might be doing wrong?
Thanks,
Virgil
This discussion has been closed.
Replies
[code]
{% if not dynamic %}
{% for invoice in invoices %}
...
{% endfor %}
{% endif %}
[/code]
If I copy the output into the html template directly it works great. Any idea about why this could be?
So I guess the problem is caused by the datatable. Any idea why this could be?
Thanks