dojox/grid/enhanced/plugins/Cookie (version 1.10)

dojox/grid/enhanced/_Plugin

Summary

This plugin provides a way to persist some grid features in cookie. Default persistable features are: column width: "columnWidth" (handler name) column order: "columnOrder" sorting order: "sortOrder"

Grid users can define new persistable features by calling the following before grid is initialized (that is, during "preInit");

grid.addCookieHandler({
    name: "a name for the new persistable feature",
    onLoad: function(savedObject, grid){
        //load the cookie.
    },
    onSave: function(grid){
        //save the cookie.
    }
});

Usage

var foo = new Cookie(grid,args);
dojox/grid/enhanced/plugins/Cookie
Parameter Type Description
grid undefined
args undefined

Property Summary

  • _connectsList of all connections.
  • _cookieEnabled
  • _subscribesList of all subscribes.
  • gridGrid that the plugin belongs to
  • namePlugin name
  • optionPlugin properties - leveraged with default and user specified properties. e.g. for dnd plugin, it may look like {"class": dojox.grid.enhanced.plugins.DnD, "dependency": ["nestedSorting"], ...}
  • privatesPrivate properties/methods shouldn't be mixin-ed anytime.

Method Summary

  • _mixinGrid()
  • _saveCookie()
  • addCookieHandler(args) If a grid plugin wants cookie service, call this.
  • connect(obj,event,method) Connects specified obj/event to specified method of this object.
  • destroy()
  • disconnect(handle) Disconnects handle and removes it from connection list.
  • getCookieEnabled(cookieName) A getter to check cookie support of a particular Grid feature.
  • init()
  • removeCookie() Remove cookie for this grid.
  • setCookieEnabled(cookieName,enabled) A setter to enable|disable cookie support for a particular Grid feature.
  • subscribe(topic,method) Subscribes to the specified topic and calls the specified method of this object.
  • unsubscribe(handle) Un-subscribes handle and removes it from subscriptions list.

Event Summary

Properties

_connects

List of all connections.

_cookieEnabled
_subscribes

List of all subscribes.

grid

Grid that the plugin belongs to

name

Plugin name

option

Plugin properties - leveraged with default and user specified properties. e.g. for dnd plugin, it may look like {"class": dojox.grid.enhanced.plugins.DnD, "dependency": ["nestedSorting"], ...}

privates

Private properties/methods shouldn't be mixin-ed anytime.

Methods

_mixinGrid()
_saveCookie()
addCookieHandler(args)

If a grid plugin wants cookie service, call this. This must be called during preInit.

Parameter Type Description
args Object

An object with the following structure:

{
    name: "some-string",
    onLoad: /* void */ function(/* object */partOfCookie, /* EDG */grid){...},
    onSave: /* object */ function(/* EDG */grid){...}
}
connect(obj,event,method)

Connects specified obj/event to specified method of this object.

Parameter Type Description
obj undefined
event undefined
method undefined
Returns:undefined

Examples

Example 1

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
});
destroy()
disconnect(handle)

Disconnects handle and removes it from connection list.

Parameter Type Description
handle undefined
getCookieEnabled(cookieName)

A getter to check cookie support of a particular Grid feature.

Parameter Type Description
cookieName String
Optional

Name of a cookie handler if provided, otherwise for all cookies.

Returns:undefined | boolean
init()
removeCookie()

Remove cookie for this grid.

setCookieEnabled(cookieName,enabled)

A setter to enable|disable cookie support for a particular Grid feature.

Parameter Type Description
cookieName String
Optional

Name of a cookie handler if provided, otherwise for all cookies.

enabled Boolean
subscribe(topic,method)

Subscribes to the specified topic and calls the specified method of this object.

Parameter Type Description
topic undefined
method undefined
Returns:undefined

Examples

Example 1

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
});
unsubscribe(handle)

Un-subscribes handle and removes it from subscriptions list.

Parameter Type Description
handle undefined

Events

onPostInit()

Examples

Example 1

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
});
onPreInit()

Examples

Example 1

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
});
onSetStore(store)

Called when store is changed.

Parameter Type Description
store undefined

Examples

Example 1

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
});
onStartUp()

Examples

Example 1

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
});
Error in the documentation? Can’t find what you are looking for? Let us know!