bSort, bSortable and 'mousedown' event

bSort, bSortable and 'mousedown' event

MadLordMadLord Posts: 10Questions: 0Answers: 0
edited September 2010 in General
i use DataTables 1.7.0...my table initialize so:
[code]
oTable = $('#table').dataTable(
{
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": url,
"bSortClasses": false,
"aoColumns":
[
/* th1 */ { "bSortable": false},
/* th2 */ { "bSortable": false},
/* th3 */ { "bSortable": false}
]
})
[/code]

and my html(with individual column filtering):
[code]



TH1 name



TH2 name



TH3 name








[/code]

i found some strange - when i right click on input in head(Mozilla 3.6.8) focus and blur not work!.....but in IE8 it`s work!...
I used Visual Event and have seen what DataTables add on th 'mousedown' event in _fnDrawHead function...
[code]
/*
* Function: _fnDrawHead
* Purpose: Create the HTML header for the table
* Returns: -
* Inputs: object:oSettings - dataTables settings object
*/
function _fnDrawHead( oSettings )
{
/* some code */
/* Take the brutal approach to cancelling text selection in header */
$('th', oSettings.nTHead).mousedown( function (e) {
this.onselectstart = function() { return false; };
return false;
}
[/code]
It happens when variable "bSort" is true....when i read this:
"bSort - Enable or disable sorting of columns. Sorting of individual columns can be disabled by the "bSortable" option for each column."
But after all all my columns have parameter bSortable!....why DataTables all the same add this event?...
this is very starnge...maybe default for bSort must be false?....

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Very good point! Thanks for picking up on this. Yes bSort would address this, but I think the event handler which is being added (to cancel text selection) shouldn't be added at this point. Looking at the code the following block

    [code]
    /* Take the brutal approach to cancelling text selection in header */
    $('th', oSettings.nTHead).mousedown( function (e) {
    this.onselectstart = function() { return false; };
    return false;
    } );
    [/code]
    Should come just after the call to _fnSortAttachListener() a few lines before (in that 'if' block). That should take care of that. This will be in the next release.

    Regards,
    Allan
  • MadLordMadLord Posts: 10Questions: 0Answers: 0
    edited September 2010
    Oh!...i see )))...i think this should be so:
    [code]
    /* Add sort listener */
    if ( oSettings.oFeatures.bSort )
    {
    for ( i=0 ; i
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yup exactly like that :-). Visual Event is useful for checking what events are attached to what: http://www.sprymedia.co.uk/article/Visual+Event - in this case you should now be able to see that there are no events attached to the TH elements.

    Regards,
    Allan
This discussion has been closed.