FurtiveFelon
FurtiveFelon

Reputation: 15176

how to disable click to sort on yui datatable?

I would like to move "click heading to sort" to "double click heading to sort". So currently i'm doing it with the following two lines:

table.unsubscribe("theadCellClickEvent", TAG.content.table.onEventSortColumn);
table.subscribe("theadCellDblclickEvent", TAG.content.table.onEventSortColumn);

However, when i do this, and i click on the heading, it will take me to folder/thead-id (since by default there is a "a" tag wrapped around the heading text.

Any idea how to do it properly?

Thanks a lot!

Jason

Upvotes: 2

Views: 1111

Answers (1)

Matthew Smith
Matthew Smith

Reputation: 1287

You have to stop the default click event. Create a new event handler for the click event that simply stops bubbling the event.

    var stopEvent = function(oArgs) {
        var evt = oArgs.event;
        YAHOO.util.Event.stopEvent(evt);
    };

    table.unsubscribe("theadCellClickEvent", TAG.content.table.onEventSortColumn);
    table.subscribe("theadCellClickEvent", stopEvent);
    table.subscribe("theadCellDblclickEvent", TAG.content.table.onEventSortColumn);

Upvotes: 2

Related Questions