dojox/grid/enhanced/_Plugin.js

  • Provides:

    • dojox.grid.enhanced._Plugin
  • Requires:

    • dojox.grid.EnhancedGrid in common
  • dojox.grid.enhanced._Plugin

    • type
      Function
    • summary
      Base class for all plugins.
    • description
      Provides common plugin functionality and basic life cycle management.
      
      Each concrete plugin must have a name field and is responsible for registering itself to the global plugin registry
      e.g. for dnd plugin:
      		dojox.grid.EnhancedGrid.registerPlugin("dnd" /*plugin name*/,
      												dojox.grid.enhanced.plugins.DnD /*full class name of a plugin*/
      												{"preInit": false, "dependency": ["nestedSorting"]} /*properties*/);
      
      [Keywords] of plugin properties(case sensitive)
      - "preInit": boolean, whether a plugin should be created before EnhancedGrid.postCreate(),
      false by default(plugins are created after EnhancedGrid.postCreate()).
      - "dependency": array or string, plugin(s) indicated by "dependency" will be created before the current one.
      Note: recursive cycle dependencies are not supported e.g. following dependency is invalid:
      pluginA -> pluginB -> pluginA
    • example
      1. Customize default DnD plugin
      
      	dojo.declare("mygrid.MyDnD", dojox.grid.enhanced.plugins.DnD, {
      		name:"dnd" //still reuse the plugin name
      		constructor: function(inGrid, option){ ... }
      	});
      	dojox.grid.EnhancedGrid.registerPlugin("dnd", mygrid.MyDnD);
      
      
      2. Add new plugin - PluginA
      	dojo.declare("mygrid.PluginA", dojox.grid.enhanced._Plugin, {
      		name: "pA",
      		constructor: function(inGrid, option){ ... }
      	});
      	dojox.grid.EnhancedGrid.registerPlugin("pA",mygrid.PluginA);
      
      3. Use plugins
      	dojo.require("mygrid.MyDnD");
      	dojo.require("mygrid.PluginA");
      
      	<script type="text/javascript">
      		var grid = new dojox.grid.EnhancedGrid(
      		{plugins: {dnd:true, pA:true}, ... }, dojo.byId("gridDiv"));
      		grid.startup();
      	</script>
    • parameters:
      • inGrid: (typeof )
      • option: (typeof )
    • source: [view]
        this.grid = inGrid;
        this.option = option;
        this._connects = [];
        this._subscribes = [];
        this.privates = dojo.mixin({},dojox.grid.enhanced._Plugin.prototype);
        this.init();
  • dojox.grid.enhanced._Plugin.name

    • type
      String
    • summary
      Plugin name, e.g. 'nestedSorting', 'dnd'...
  • dojox.grid.enhanced._Plugin.grid

    • type
      Object
    • summary
      Grid that the plugin belongs to
  • dojox.grid.enhanced._Plugin.option

    • type
      Object
    • summary
  • dojox.grid.enhanced._Plugin._connects

    • type
      Array
    • summary
      List of all connections.
  • dojox.grid.enhanced._Plugin._subscribes

    • type
      Array
    • summary
      List of all subscribes.
  • dojox.grid.enhanced._Plugin.privates

    • type
      Object
    • summary
  • dojox.grid.enhanced._Plugin.init

    • type
      Function
    • source: [view]
      }
    • summary
  • dojox.grid.enhanced._Plugin.onPreInit

    • type
      Function
    • source: [view]
      }
    • summary
  • dojox.grid.enhanced._Plugin.onPostInit

    • type
      Function
    • source: [view]
      }
    • summary
  • dojox.grid.enhanced._Plugin.onStartUp

    • type
      Function
    • source: [view]
      }
    • summary
  • dojox.grid.enhanced._Plugin.connect

    • type
      Function
    • parameters:
      • obj: (typeof )
      • event: (typeof )
      • method: (typeof )
    • source: [view]
        var conn = dojo.connect(obj, event, this, method);
        this._connects.push(conn);
        return conn;
    • summary
      Connects specified obj/event to specified method of this object.
    • example
      
      	var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
      	// when foo.bar() is called, call the listener in the scope of plugin
      	plugin.connect(foo, "bar", function(){
      		console.debug(this.xxx());//"this" - plugin scope
      	});
  • dojox.grid.enhanced._Plugin.disconnect

    • type
      Function
    • parameters:
      • handle: (typeof )
    • source: [view]
        dojo.some(this._connects, function(conn, i, conns){
         if(conn == handle){
          dojo.disconnect(handle);
          conns.splice(i, 1);
          return true;
         }
         return false;
        });
    • summary
      Disconnects handle and removes it from connection list.
  • dojox.grid.enhanced._Plugin.subscribe

    • type
      Function
    • parameters:
      • topic: (typeof )
      • method: (typeof )
    • source: [view]
        var subscribe = dojo.subscribe(topic, this, method);
        this._subscribes.push(subscribe);
        return subscribe;
    • summary
      Subscribes to the specified topic and calls the specified method
      of this object.
    • example
      
      	var plugin = new dojox.grid.enhanced._Plugin(grid,"myPlugin",{...});
      	// when /my/topic is published, call the subscriber in the scope of plugin
      	// with passed parameter - "v"
      	plugin.subscribe("/my/topic", function(v){
      		console.debug(this.xxx(v));//"this" - plugin scope
      	});
  • dojox.grid.enhanced._Plugin.unsubscribe

    • type
      Function
    • parameters:
      • handle: (typeof )
    • source: [view]
        dojo.some(this._subscribes, function(subscribe, i, subscribes){
         if(subscribe == handle){
          dojo.unsubscribe(handle);
          subscribes.splice(i, 1);
          return true;
         }
         return false;
        });
    • summary
      Un-subscribes handle and removes it from subscriptions list.
  • dojox.grid.enhanced._Plugin.onSetStore

    • type
      Function
    • parameters:
      • store: (typeof )
    • source: [view]
        // summary:
        //  Called when store is changed.
    • summary
      Called when store is changed.
  • dojox.grid.enhanced._Plugin.destroy

    • type
      Function
    • source: [view]
        dojo.forEach(this._connects, dojo.disconnect);
        dojo.forEach(this._subscribes, dojo.unsubscribe);
        delete this._connects;
        delete this._subscribes;
        delete this.option;
        delete this.privates;
        //console.log('Plugin [', this.name, '].destroy() executed!');
    • summary
      Destroy all resources.
  • dojox.grid.enhanced

    • type
      Object
    • summary
  • dojox.grid

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary