Search code examples
yuiyui-datatable

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


Solution

  • 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);