API Docs for:
Show:

Y.Plugin.DataTableContextMenu Class

This module defines a plugin that creates up to three gallery-contextmenu-view instances on a single DataTable, each delegated to the contextmenu event on the THEAD, TBODY and TFOOT containers.

A typical use case might be as follows;

   // Create a DT with local data ...
   var myDT = new Y.DataTable({
       data: mydata,
       columns: mycolumns
   }).render();

   // plugin this module to give a right-click menu on the TBODY and the THEAD
   //    tdMenuChange and thMenuSelect are functions defined to respond to
   //    context menu choices (not shown ... see examples)
   myDT.plug(Y.Plugin.DataTableContextMenu,{
       // This is a contextmenu on the TD nodes ...
       tbodyMenu:{
           menuItems: [
               {label:"Edit",  value:"e" },
               {label:"Update", value:"u"},
               {label:"Delete Record", value:"d"}
           ],
           after:{
             'selectedMenuChange': tdMenuChange
           }
       },

       // and this is a contextmenu on the header TH nodes ...
       theadMenu:{
           menuItems:  [ "Sort A-Z",  "Sort Z-A",  "Hide" ],
           after: {
               'selectedMenuChange': thMenuSelect
           }
       }
   });

Methods

_buildUI

() private

This method constructs the three context-menu View instances for this DT if the appropriate ATTRS are defined

_makeTbodyCMenu

() private

Creates the context menu on the DT's header components, based upon the ATTR "tbodyMenu" settings.

_makeTfootCMenu

() private

Creates the context menu on the DT's footer components, based upon the ATTR "tfootMenu" settings.

_makeTheadCMenu

() private

Creates the context menu on the DT's header components, based upon the ATTR "theadMenu" settings.

_onHostRenderViewEvent

() private

This listener fires after DT's "renderView" event, which means that the DT has had it's UI constructed and displayed. We use it in case the implementer plugged in this module to the DT before the render call.

destructor

() public

Destroys each of the View instances of the menu and nulls them out

hideCM

(
  • mname
)
public

Helper method to hide the display of a DT contextmenu attached

Parameters:

  • mname String

    Name of context menu property on this Plugin

initializer

() public

Called when this plugin is created. If the DT has been rendered the Views will be created, otherwise a listener is set to create them after DT "renderView" fires.

Properties

_menuItemTemplate

String deprecated static

Default: See Code

NAME

String static

Plugin name and event name prefix for this dt-contextmenu

Default: 'DtContextMenu'

NS

String static

Namespace property for this dt-contexmenu plugin, you can access this from a DT instance as mydatatable.contextmenu

Default: 'contextmenu'

tbodyCMenu

View static

Placeholder for the View instance for the tbodyMenu ...

Default: null

tfootCMenu

View static

Placeholder for the View instance for the tfootMenu ...

Default: null

theadCMenu

View static

Placeholder for the View instance for the theadMenu ...

Default: null

Attributes

tbodyMenu

Object

Configuration object properties for the TBODY contextmenu-view View instance

Default: null

tfootMenu

Object

Configuration object properties for the TFOOT contextmenu-view View instance

Default: null

theadMenu

Object

Configuration object properties for the THEAD contextmenu-view View instance

Default: null