Debian Codegraph @

dojox/grid/enhanced/plugins/exporter/_ExportWriter.js

raw symbols SCIP
1 define([
2 "dojo/_base/declare"
3 ], function(declare){
4 //require Exporter here, so the implementations only need to require this file,
5 //and the users only need to require the implementation file.
6
7 return declare("dojox.grid.enhanced.plugins.exporter._ExportWriter", null, {
8 // summary:
9 // This is an abstract class for all kinds of writers used in the Exporter plugin.
10 // It utilizes the strategy pattern to break the export work into several stages,
11 // and provide interfaces for all of them.
12 //
13 // Implementations might choose some of the functions in this class to override,
14 // thus providing their own functionalities.
15 //
16 // The Exporter will go through the grid line by line. So in every line, all the Views
17 // will be reached, and the header line is only handled once.
18 //
19 // An *argObj* object is passed to most functions of this class.
20 // It carries context arguments that make sense when they are called.
21
22 /*=====
23 argObj: {
24 // grid: EnhancedGrid
25 // The grid object we are now handling.
26 grid: null,
27
28 // isHeader: bool
29 // Indicating which context we're handling, header or content.
30 isHeader: true,
31
32 // view: _View
33 // Reference to the current _View object.
34 view: null,
35
36 // viewIdx: int
37 // The index of the current _View object in the views array.
38 // If the grid does not have any rowselector view, it conforms to the index
39 // in the _ViewManager.views.
40 viewIdx: -1,
41
42 // subrow: _View.structure.cells[i]
43 // Reference to the current subrow.
44 // A subrow describe the innter structure of a row in a view, it's an array of cells
45 subrow: null,
46
47 // subrowIdx: int
48 // The index of the current subrow in the subrow array: _View.structure.cells.
49 subrowIdx: -1,
50
51 // cell: dojox.grid.__CellDef
52 // Reference to the current cell.
53 cell: null,
54
55 // cellIdx: int
56 // The index of the current cell in the current subrow.
57 // It's different from cell.index, which is the index in the whole line.
58 cellIdx: -1,
59
60 // row: item
61 // The current row of data (logically), a.k.a.: current item.
62 row: null,
63
64 // rowIdx: int
65 // The index of the current row (item).
66 rowIdx: -1,
67
68 // spCols: int[]
69 // An array of special column indexes(flat,not regarding structure).
70 // Special columns are typically attached to grid as a kind of UI facility
71 // by the grid widget, instead of some real data.
72 // For example, indirect selectors and row indexers.
73 // Users can choose to export it or not.
74 spCols: [],
75
76 // colOffset: int
77 // If the grid has a _RowSelector view or something else, this view will NOT be
78 // passed to the user in argObj. So the column index (cell.index) will appear shifted
79 // (start from 1 instead of 0). This colOffset is provided to remove this shift.
80 //
81 // usage:
82 // | var correctColIndex = argObj.cell.index + argObj.colOffset;
83 colOffset: 0
84 },
85 =====*/
86
87 constructor: function(/* object? */writerArgs){
88 // summary:
89 // Writer initializations goes here.
90 // writerArgs: object?
91 // Any implementation of this class might accept a writerArgs object (optional),
92 // which contains some writer-specific arguments given by the user.
93 },
94 _getExportDataForCell: function(rowIndex, rowItem, cell, grid){
95 var data = (cell.get || grid.get).call(cell, rowIndex, rowItem);
96 if(this.formatter){
97 return this.formatter(data, cell, rowIndex, rowItem);
98 }else{
99 return data;
100 }
101 },
102 beforeHeader: function(/* EnhancedGrid */grid){
103 // summary:
104 // We are going to start the travel in the grid.
105 // Is there anything we should do now?
106 // tags:
107 // protected extension
108 // returns:
109 // - true: go on handling the header row and then call afterHeader.
110 // - false: skip the header row, won't call afterHeader.
111 return true; //Boolean
112 },
113 afterHeader: function(){
114 // summary:
115 // The header line has been handled.
116 // tags:
117 // protected extension
118 // returns:
119 // undefined
120 },
121 beforeContent: function(/* Array */items){
122 // summary:
123 // We are ready to go through all the contents(items).
124 // tags:
125 // protected extension
126 // items:
127 // All the items fetched from the store
128 // returns:
129 // - true: go on handling the contents and then call afterContent.
130 // - false: skip all the contents, won't call afterContent.
131 return true; //Boolean
132 },
133 afterContent: function(){
134 // summary:
135 // We have finished the entire grid travel.
136 // Do some clean up work if you need to.
137 // tags:
138 // protected extension
139 // returns:
140 // undefined
141 },
142 beforeContentRow: function(/* object */argObj){
143 // summary:
144 // Before handling a line of data (not header).
145 // tags:
146 // protected extension
147 // argObj:
148 // An object with at least the following context properties available:
149 // | {
150 // | grid,isHeader,
151 // | row,rowIdx,
152 // | spCols
153 // | }
154 // returns:
155 // - true: go on handling the current data row and then call afterContentRow.
156 // - false: skip the current data row, won't call afterContentRow.
157 return true; //Boolean
158 },
159 afterContentRow: function(/* object */argObj){
160 // summary:
161 // After handling a line of data (not header).
162 // tags:
163 // protected extension
164 // argObj:
165 // An object with at least the following context properties available:
166 // | {
167 // | grid,isHeader,
168 // | row,rowIdx,
169 // | spCols
170 // | }
171 // returns:
172 // undefined
173 },
174 beforeView: function(/* object */argObj){
175 // summary:
176 // Before handling a view.
177 // tags:
178 // protected extension
179 // argObj:
180 // An object with at least the following context properties available:
181 // | {
182 // | grid,isHeader,
183 // | view,viewIdx,
184 // | spCols(if isHeader==false)
185 // | }
186 // returns:
187 // - true: go on handling the current view and then call afterView.
188 // - false: skip the current view, won't call afterView.
189 return true; //Boolean
190 },
191 afterView: function(/* object */argObj){
192 // summary:
193 // After handling a view.
194 // tags:
195 // protected extension
196 // argObj:
197 // An object with at least the following context properties available:
198 // | {
199 // | grid,isHeader,
200 // | view,viewIdx,
201 // | spCols(if isHeader==false)
202 // | }
203 // tags:
204 // protected extension
205 // returns:
206 // undefined
207 },
208 beforeSubrow: function(/* object */argObj){
209 // summary:
210 // Before handling a subrow in a line (defined in the grid structure).
211 // tags:
212 // protected extension
213 // argObj:
214 // An object with at least the following context properties available:
215 // | {
216 // | grid,isHeader,
217 // | row,rowIdx,
218 // | view,viewIdx,
219 // | subrow,subrowIdx,
220 // | spCols(if isHeader==false)
221 // | }
222 // returns:
223 // - true: go on handling the current subrow and then call afterSubrow.
224 // - false: skip the current subrow, won't call afterSubrow.
225 return true; //Boolean
226 },
227 afterSubrow: function(/* object */argObj){
228 // summary:
229 // Before handling a subrow in a line (defined in the grid structure).
230 // tags:
231 // protected extension
232 // argObj:
233 // An object with at least the following context properties available:
234 // | {
235 // | grid,isHeader,
236 // | row,rowIdx,
237 // | view,viewIdx,
238 // | subrow,subrowIdx,
239 // | spCols(if isHeader==false)
240 // | }
241 // returns:
242 // undefined
243 },
244 handleCell: function(/* object */argObj){
245 // summary:
246 // Handle a header cell or data cell.
247 // tags:
248 // protected extension
249 // argObj:
250 // An object with at least the following context properties available:
251 // | {
252 // | grid,isHeader,
253 // | row,rowIdx,
254 // | view,viewIdx,
255 // | subrow,subrowIdx,
256 // | cell,cellIdx,
257 // | spCols(if isHeader==false)
258 // | }
259 // returns:
260 // undefined
261 },
262 toString: function(){
263 // summary:
264 // Export to a string.
265 // tags:
266 // protected extension
267 // returns:
268 // The exported result string.
269 return ''; //String
270 }
271 });
272 });