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

dojox/grid/enhanced/_Plugin

Summary

Provide functions to export the grid data into a given format.

Acceptable plugin parameters:

  1. exportFormatter: function(data, cell, rowIndex, item) Provide a way to customize how data should look in exported string. Note that usually the formatter of grid cell should not be used here (it can return HTML or even widget).

Usage

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

The grid to plug in to.

args undefined

Examples

Example 1

function onExported(exported_text){
    //custom code here...
}
dijit.byId("my_grid_id").exportTo("csv",    //registered export format, mandatory
    {                                       //the whole object is optional.
        fetchArgs: {start:0,count:1000},    //keywordArgs for fetch, optional
        writerArgs: {separator:';'},        //export writer specific arguments, optional
    },
    function(str){
        //call back function, mandatory
});
var result = dijit.byId("my_grid_id").exportSelectedTo("table",     //registered export format, mandatory
                                                    {separator:'|'} //export writer specific arguments, optional
);

Property Summary

  • _connectsList of all connections.
  • _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.
  • writerNames

Method Summary

  • _buildRow(arg_obj,writer) Use the given export writer(writer) to go through a single row which is given in the context object(arg_obj).
  • _getExportWriter(fileType,writerArgs) Use the given export format type(fileType) and writer arguments(writerArgs) to create a ExportWriter and return it.
  • _goThroughGridData(items,writer) Use the given export writer(writer) to go through the grid structure and the given rows(items), then return the writer output.
  • _isSpecialCol(header_cell) Row selectors and row indexes should be recognized and handled separately.
  • _mixinGrid()
  • connect(obj,event,method) Connects specified obj/event to specified method of this object.
  • destroy() Destroy all resources.
  • disconnect(handle) Disconnects handle and removes it from connection list.
  • exportGrid(type,args,onExported) Export required rows(fetchArgs) to a kind of format(type) using the corresponding writer with given arguments(writerArgs), then pass the exported text to a given function(onExported).
  • exportSelected(type,writerArgs,onExported) Only export selected rows.
  • init()
  • registerWriter(fileType,writerClsName) Register a writer(writerClsName) to a export format type(fileType).
  • setExportFormatter(formatter)
  • 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.

_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

_buildRow(arg_obj,writer)

Use the given export writer(writer) to go through a single row which is given in the context object(arg_obj).

Parameter Type Description
arg_obj object
writer ExportWriter
Returns:any

undefined

_getExportWriter(fileType,writerArgs)

Use the given export format type(fileType) and writer arguments(writerArgs) to create a ExportWriter and return it.

Parameter Type Description
fileType string
writerArgs object
Optional
Returns:instance
_goThroughGridData(items,writer)

Use the given export writer(writer) to go through the grid structure and the given rows(items), then return the writer output.

Parameter Type Description
items Array
writer ExportWriter
Returns:undefined
_isSpecialCol(header_cell)

Row selectors and row indexes should be recognized and handled separately.

Parameter Type Description
header_cell dojox.grid.__CellDef
Returns:boolean
_mixinGrid()
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()

Destroy all resources.

disconnect(handle)

Disconnects handle and removes it from connection list.

Parameter Type Description
handle undefined
exportGrid(type,args,onExported)

Export required rows(fetchArgs) to a kind of format(type) using the corresponding writer with given arguments(writerArgs), then pass the exported text to a given function(onExported).

Parameter Type Description
type String

A registered export format name

args Object
Optional

includes:

{
    fetchArgs: object?
        Any arguments for store.fetch
    writerArgs: object?
        Arguments for the given format writer
}
onExported undefined

Call back function when export result is ready

exportSelected(type,writerArgs,onExported)

Only export selected rows.

Parameter Type Description
type string

A registered export format name

writerArgs object
Optional

Arguments for the given format writer

onExported undefined
Returns:string | undefined

The exported string

init()
registerWriter(fileType,writerClsName)

Register a writer(writerClsName) to a export format type(fileType). This function separates the Exporter from all kinds of writers.

Parameter Type Description
fileType string
writerClsName string
setExportFormatter(formatter)
Parameter Type Description
formatter undefined
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!