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

ContextMenu in DataTable

Expand Messages
  • Eric Cire
    Hi Group, Is there a way to alert the column name of a DataTable column I am in when I right click and bring up a ContextMenu? I want to have different context
    Message 1 of 12 , Feb 25, 2010
    • 0 Attachment
      Hi Group,

      Is there a way to alert the column name of a DataTable column I am in when I right click and bring up a ContextMenu? I want to have different context menus based on which column I am in, and was not able to get it working.

      I am using YUI 2.7.0 and the code I am working on is below.

      Thank you.

      Code:

          function registerBodyMenus(ColumnDefs){

                  YAHOO.util.Event.onContentReady(self.containerDiv, function () {

                      var bodyContextMenu = new YAHOO.widget.ContextMenu("bodycontextmenu", {
                          trigger: self.dataTable.getTbodyEl()
                      });

                      bodyContextMenu.addItem("Click To Get Column Name");
                      bodyContextMenu.render( self.containerDiv );
                      alert(ColumnDefs);  // Gives me array [object Object]... for each column I have
                      bodyContextMenu.clickEvent.subscribe( onBodyMenuClick, self.dataTable );

                  });
              }

              var onBodyMenuClick = function( p_sType, p_aArgs, ColumnDefs ){
                  var task = p_aArgs[1];
                  if( task ) {
                     
                      switch( task.index ) {
                          case 0:
                              alert(ColumnDefs);  // Gives me: DataTable instance yui-dt0
                              alert(ColumnDefs.getKey());  // Does not alert
                              return;
                      }
                  }
              }

    Your message has been successfully submitted and would be delivered to recipients shortly.