Loading ...
Sorry, an error occurred while loading the content.

52467Re: ContextMenu in DataTable Header

Expand Messages
  • Matt
    Feb 19, 2010
    • 0 Attachment
      Hi Eric,

      In your context menu config you've got
      trigger: self.dataTable.getTbodyEl()
      which will attach it to the body of the table. Replace with
      trigger: self.dataTable.getTheadEl()

      and it'll attach to the head.

      I've just done an extension to datatable to do exactly this, it's at
      http://github.com/mattparker/Yui-DataTable-extension---column-chooser

      if you want to take a look.

      Matt


      --- In ydn-javascript@yahoogroups.com, Eric Cire <codedude11@...> wrote:
      >
      > Hi Group,
      >
      > I am creating a DataTable and I need to add a ContextMenu to a header, not the body of the table. I have a table contextMenu working fine, but not sure how to link it to the header. Any ideas? The code is below.
      >
      > Using YUI 2.7.0.
      >
      > Thank you !
      >
      > Code:
      >
      > var onContextMenuClick = function( p_sType, p_aArgs ){
      > var task = p_aArgs[1];
      > if(task) {
      >
      > switch(task.index) {
      > case 0: ExportFile(); return;
      > case 1: printTable(); return;
      > case 2: alert("You clicked for a message. This is a message.");
      > }
      > }
      > }
      >
      > // Function to add Menu controls.
      > function registerMenus(){
      >
      > YAHOO.util.Event.onContentReady(self.containerDiv, function () {
      >
      > var contextMenu = new YAHOO.widget.ContextMenu("contextmenu",{trigger:self.dataTable.getTbodyEl()});
      > contextMenu.addItem("Export File");
      > contextMenu.addItem("Print Page");
      > contextMenu.addItem("Click for message!");
      > contextMenu.render(self.containerDiv);
      > contextMenu.clickEvent.subscribe(onContextMenuClick, self.dataTable);
      >
      > });
      > }
      >
    • Show all 12 messages in this topic