fnSortListener Bug?
fnSortListener Bug?
chobo2
Posts: 23Questions: 2Answers: 0
Hi
I am trying to use fnSortListener on one column that triggers another columns sort.
Say I have this
Column A
Column B
When column A is clicked it should use trigger Column B sort and sort. When column A again it should sort Column B again.
For me it does not. Once you clicked on column A and triggers column B that's it forever. You can click as long as you want nothing will happen.
This is what I have
[code]
oTable= $(this).dataTable
({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumns":
[
null,
null
]
});
var columnA= $('#ColumnA');
oTable.fnSortListener(columnA, 1);
[/code]
I am trying to use fnSortListener on one column that triggers another columns sort.
Say I have this
Column A
Column B
When column A is clicked it should use trigger Column B sort and sort. When column A again it should sort Column B again.
For me it does not. Once you clicked on column A and triggers column B that's it forever. You can click as long as you want nothing will happen.
This is what I have
[code]
oTable= $(this).dataTable
({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aoColumns":
[
null,
null
]
});
var columnA= $('#ColumnA');
oTable.fnSortListener(columnA, 1);
[/code]
This discussion has been closed.
Replies
Also you are passing a jQuery object to the function, and it is expecting a node: http://datatables.net/api#fnSortListener . You can either use $(...)[0] or getElementById (which is the case above is faster).
Regards,
Allan
I am not sure what you mean by (..)[0] I am not sure what the zero is for.
How do you detach the sort listen?
2. $(..)[0] - the jQuery object is an array of nodes returned from the selector. The 0 indicates the first node found (or indeed the only only node when using an id selector)
3. The column sorting icons should show the column that is actively being sorted (so if you tell fnSortListener to sort on column 1, it will show column 1 as the one being sorted - even if the listener is actually on column 0). iDataSort is the way to overcome this rather than fnSortListener.
Allan
iDataSort = 1
So jquery always gets an array back even if your selecting an id(what should only have one?)
$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
{ "iDataSort": 1 }
null,
]
} );
} );
[/code]
Now if you click on the first column, it will indicate that it is being sorted, but the data source being used is the second column (index 1). Then click on the second column - still sorting by the second column, but shown as such.
jQuery: Yes - it's an array object with many methods and properties attached to it. Do console.dir( $('#some_id') ); in Firebug to see it.
Allan