fnLengthChange() changes the value of all my select fields
fnLengthChange() changes the value of all my select fields
Hi,
First of all, I would like to thank you for this lovely piece of coding. I'm using the code in my project at school after I was getting sick of the problems with tablesorter. This piece of code is soo much better, you rock dude.
Back to my question:
I am using the fnLengthChange plugin from your page. It works very well except that when I call the function, it will change the values in all of my select fields. I'm rather new to jQuery so I'm not really into the debugging of these big coding projects yet.
As far as I managed to trace it, the error is in this line:
[code]
$('select', oSettings.oFeatures.l).val( iDisplay );
[/code]
If I place this line in comment, then I do not have the error on my webpage. But I'm not able to trace this any further because I do not now how jQuery handles this selector with a comma and a variable. I've also checked the value of "oSettings.oFeatures.l" and it is undefined. I did a search in your jQuery file for "oFeatures.l" but couldn't find it. So I think that this plugin has a small bug there.
Could you please help me to solve this.
I hope my explanation is clear. If not, please tell my what other information you need.
Kind regards
First of all, I would like to thank you for this lovely piece of coding. I'm using the code in my project at school after I was getting sick of the problems with tablesorter. This piece of code is soo much better, you rock dude.
Back to my question:
I am using the fnLengthChange plugin from your page. It works very well except that when I call the function, it will change the values in all of my select fields. I'm rather new to jQuery so I'm not really into the debugging of these big coding projects yet.
As far as I managed to trace it, the error is in this line:
[code]
$('select', oSettings.oFeatures.l).val( iDisplay );
[/code]
If I place this line in comment, then I do not have the error on my webpage. But I'm not able to trace this any further because I do not now how jQuery handles this selector with a comma and a variable. I've also checked the value of "oSettings.oFeatures.l" and it is undefined. I did a search in your jQuery file for "oFeatures.l" but couldn't find it. So I think that this plugin has a small bug there.
Could you please help me to solve this.
I hope my explanation is clear. If not, please tell my what other information you need.
Kind regards
This discussion has been closed.
Replies
Thank you very much.
First you need the ID of the div that contains your datatable. I used the Firefox Firebug plugin to find the div being populated. In my code:
Heading 1
Heading 2
And then I added that same value from the ID attribute to my fnLengthChange code:
$('#MyDataTable select', oSettings.oFeatures.l).val(iDisplay);
That will ONLY change the selects within the datatable, not all the selects on the page!
That should work for you. If your datatable div doesn't have an id, just add one.
[code]$('select', oSettings.oFeatures.l).val( iDisplay ); [/code]
to:
[code]$('select', oSettings.aanFeatures.l).val( iDisplay ); [/code]
Allan
When I change, for example, to 20 lines per page and then go to next page, it sets iDisplayStart=020 instead of 20.
I solved it by changing
[code] oSettings._iDisplayLength = iDisplay; [/code]
to
[code] oSettings._iDisplayLength = parseInt(iDisplay);[/code]
However I think this should be fixed in _fnCalculateEnd function
Allan
[code]
if(oSettings.aanFeatures.l) {
$('select', oSettings.aanFeatures.l).val( iDisplay );
}
[/code]
Allan
I'm using the 1.9 version but the code is in the plugin fnLengthChange.
(plugins > api > fnLengthChange) It's a plug-in by Pedro Alves
Allan