Upgrade to ExtJS 3.1.1 - Released 02/08/2010
[extjs.git] / src / widgets / grid / GroupingView.js
1 /*!
2  * Ext JS Library 3.1.1
3  * Copyright(c) 2006-2010 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**\r
8  * @class Ext.grid.GroupingView\r
9  * @extends Ext.grid.GridView\r
10  * Adds the ability for single level grouping to the grid. A {@link Ext.data.GroupingStore GroupingStore}\r
11  * must be used to enable grouping.  Some grouping characteristics may also be configured at the\r
12  * {@link Ext.grid.Column Column level}<div class="mdetail-params"><ul>\r
13  * <li><code>{@link Ext.grid.Column#emptyGroupText emptyGroupText}</li>\r
14  * <li><code>{@link Ext.grid.Column#groupable groupable}</li>\r
15  * <li><code>{@link Ext.grid.Column#groupName groupName}</li>\r
16  * <li><code>{@link Ext.grid.Column#groupRender groupRender}</li>\r
17  * </ul></div>\r
18  * <p>Sample usage:</p>\r
19  * <pre><code>\r
20 var grid = new Ext.grid.GridPanel({\r
21     // A groupingStore is required for a GroupingView\r
22     store: new {@link Ext.data.GroupingStore}({\r
23         autoDestroy: true,\r
24         reader: reader,\r
25         data: xg.dummyData,\r
26         sortInfo: {field: 'company', direction: 'ASC'},\r
27         {@link Ext.data.GroupingStore#groupOnSort groupOnSort}: true,\r
28         {@link Ext.data.GroupingStore#remoteGroup remoteGroup}: true,\r
29         {@link Ext.data.GroupingStore#groupField groupField}: 'industry'\r
30     }),\r
31     colModel: new {@link Ext.grid.ColumnModel}({\r
32         columns:[\r
33             {id:'company',header: 'Company', width: 60, dataIndex: 'company'},\r
34             // {@link Ext.grid.Column#groupable groupable}, {@link Ext.grid.Column#groupName groupName}, {@link Ext.grid.Column#groupRender groupRender} are also configurable at column level\r
35             {header: 'Price', renderer: Ext.util.Format.usMoney, dataIndex: 'price', {@link Ext.grid.Column#groupable groupable}: false},\r
36             {header: 'Change', dataIndex: 'change', renderer: Ext.util.Format.usMoney},\r
37             {header: 'Industry', dataIndex: 'industry'},\r
38             {header: 'Last Updated', renderer: Ext.util.Format.dateRenderer('m/d/Y'), dataIndex: 'lastChange'}\r
39         ],\r
40         defaults: {\r
41             sortable: true,\r
42             menuDisabled: false,\r
43             width: 20\r
44         }\r
45     }),\r
46 \r
47     view: new Ext.grid.GroupingView({\r
48         {@link Ext.grid.GridView#forceFit forceFit}: true,\r
49         // custom grouping text template to display the number of items per group\r
50         {@link #groupTextTpl}: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'\r
51     }),\r
52 \r
53     frame:true,\r
54     width: 700,\r
55     height: 450,\r
56     collapsible: true,\r
57     animCollapse: false,\r
58     title: 'Grouping Example',\r
59     iconCls: 'icon-grid',\r
60     renderTo: document.body\r
61 });\r
62  * </code></pre>\r
63  * @constructor\r
64  * @param {Object} config\r
65  */\r
66 Ext.grid.GroupingView = Ext.extend(Ext.grid.GridView, {\r
67 \r
68     /**\r
69      * @cfg {String} groupByText Text displayed in the grid header menu for grouping by a column\r
70      * (defaults to 'Group By This Field').\r
71      */\r
72     groupByText : 'Group By This Field',\r
73     /**\r
74      * @cfg {String} showGroupsText Text displayed in the grid header for enabling/disabling grouping\r
75      * (defaults to 'Show in Groups').\r
76      */\r
77     showGroupsText : 'Show in Groups',\r
78     /**\r
79      * @cfg {Boolean} hideGroupedColumn <tt>true</tt> to hide the column that is currently grouped (defaults to <tt>false</tt>)\r
80      */\r
81     hideGroupedColumn : false,\r
82     /**\r
83      * @cfg {Boolean} showGroupName If <tt>true</tt> will display a prefix plus a ': ' before the group field value\r
84      * in the group header line.  The prefix will consist of the <tt><b>{@link Ext.grid.Column#groupName groupName}</b></tt>\r
85      * (or the configured <tt><b>{@link Ext.grid.Column#header header}</b></tt> if not provided) configured in the\r
86      * {@link Ext.grid.Column} for each set of grouped rows (defaults to <tt>true</tt>).\r
87      */\r
88     showGroupName : true,\r
89     /**\r
90      * @cfg {Boolean} startCollapsed <tt>true</tt> to start all groups collapsed (defaults to <tt>false</tt>)\r
91      */\r
92     startCollapsed : false,\r
93     /**\r
94      * @cfg {Boolean} enableGrouping <tt>false</tt> to disable grouping functionality (defaults to <tt>true</tt>)\r
95      */\r
96     enableGrouping : true,\r
97     /**\r
98      * @cfg {Boolean} enableGroupingMenu <tt>true</tt> to enable the grouping control in the column menu (defaults to <tt>true</tt>)\r
99      */\r
100     enableGroupingMenu : true,\r
101     /**\r
102      * @cfg {Boolean} enableNoGroups <tt>true</tt> to allow the user to turn off grouping (defaults to <tt>true</tt>)\r
103      */\r
104     enableNoGroups : true,\r
105     /**\r
106      * @cfg {String} emptyGroupText The text to display when there is an empty group value (defaults to <tt>'(None)'</tt>).\r
107      * May also be specified per column, see {@link Ext.grid.Column}.{@link Ext.grid.Column#emptyGroupText emptyGroupText}.\r
108      */\r
109     emptyGroupText : '(None)',\r
110     /**\r
111      * @cfg {Boolean} ignoreAdd <tt>true</tt> to skip refreshing the view when new rows are added (defaults to <tt>false</tt>)\r
112      */\r
113     ignoreAdd : false,\r
114     /**\r
115      * @cfg {String} groupTextTpl The template used to render the group header (defaults to <tt>'{text}'</tt>).\r
116      * This is used to format an object which contains the following properties:\r
117      * <div class="mdetail-params"><ul>\r
118      * <li><b>group</b> : String<p class="sub-desc">The <i>rendered</i> value of the group field.\r
119      * By default this is the unchanged value of the group field. If a <tt><b>{@link Ext.grid.Column#groupRenderer groupRenderer}</b></tt>\r
120      * is specified, it is the result of a call to that function.</p></li>\r
121      * <li><b>gvalue</b> : Object<p class="sub-desc">The <i>raw</i> value of the group field.</p></li>\r
122      * <li><b>text</b> : String<p class="sub-desc">The configured header (as described in <tt>{@link #showGroupName})</tt>\r
123      * if <tt>{@link #showGroupName}</tt> is <tt>true</tt>) plus the <i>rendered</i> group field value.</p></li>\r
124      * <li><b>groupId</b> : String<p class="sub-desc">A unique, generated ID which is applied to the\r
125      * View Element which contains the group.</p></li>\r
126      * <li><b>startRow</b> : Number<p class="sub-desc">The row index of the Record which caused group change.</p></li>\r
127      * <li><b>rs</b> : Array<p class="sub-desc">Contains a single element: The Record providing the data\r
128      * for the row which caused group change.</p></li>\r
129      * <li><b>cls</b> : String<p class="sub-desc">The generated class name string to apply to the group header Element.</p></li>\r
130      * <li><b>style</b> : String<p class="sub-desc">The inline style rules to apply to the group header Element.</p></li>\r
131      * </ul></div></p>\r
132      * See {@link Ext.XTemplate} for information on how to format data using a template. Possible usage:<pre><code>\r
133 var grid = new Ext.grid.GridPanel({\r
134     ...\r
135     view: new Ext.grid.GroupingView({\r
136         groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'\r
137     }),\r
138 });\r
139      * </code></pre>\r
140      */\r
141     groupTextTpl : '{text}',\r
142 \r
143     /**\r
144      * @cfg {String} groupMode Indicates how to construct the group identifier. <tt>'value'</tt> constructs the id using\r
145      * raw value, <tt>'display'</tt> constructs the id using the rendered value. Defaults to <tt>'value'</tt>.\r
146      */\r
147     groupMode: 'value',\r
148 \r
149     /**\r
150      * @cfg {Function} groupRenderer This property must be configured in the {@link Ext.grid.Column} for\r
151      * each column.\r
152      */\r
153 \r
154     // private\r
155     gidSeed : 1000,\r
156 \r
157     // private\r
158     initTemplates : function(){\r
159         Ext.grid.GroupingView.superclass.initTemplates.call(this);\r
160         this.state = {};\r
161 \r
162         var sm = this.grid.getSelectionModel();\r
163         sm.on(sm.selectRow ? 'beforerowselect' : 'beforecellselect',\r
164                 this.onBeforeRowSelect, this);\r
165 \r
166         if(!this.startGroup){\r
167             this.startGroup = new Ext.XTemplate(\r
168                 '<div id="{groupId}" class="x-grid-group {cls}">',\r
169                     '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div class="x-grid-group-title">', this.groupTextTpl ,'</div></div>',\r
170                     '<div id="{groupId}-bd" class="x-grid-group-body">'\r
171             );\r
172         }\r
173         this.startGroup.compile();\r
174         if(!this.endGroup){\r
175             this.endGroup = '</div></div>';\r
176         }\r
177 \r
178         this.endGroup = '</div></div>';\r
179     },\r
180 \r
181     // private\r
182     findGroup : function(el){\r
183         return Ext.fly(el).up('.x-grid-group', this.mainBody.dom);\r
184     },\r
185 \r
186     // private\r
187     getGroups : function(){\r
188         return this.hasRows() ? this.mainBody.dom.childNodes : [];\r
189     },\r
190 \r
191     // private\r
192     onAdd : function(){\r
193         if(this.canGroup() && !this.ignoreAdd){\r
194             var ss = this.getScrollState();\r
195             this.refresh();\r
196             this.restoreScroll(ss);\r
197         }else if(!this.canGroup()){\r
198             Ext.grid.GroupingView.superclass.onAdd.apply(this, arguments);\r
199         }\r
200     },\r
201 \r
202     // private\r
203     onRemove : function(ds, record, index, isUpdate){\r
204         Ext.grid.GroupingView.superclass.onRemove.apply(this, arguments);\r
205         var g = document.getElementById(record._groupId);\r
206         if(g && g.childNodes[1].childNodes.length < 1){\r
207             Ext.removeNode(g);\r
208         }\r
209         this.applyEmptyText();\r
210     },\r
211 \r
212     // private\r
213     refreshRow : function(record){\r
214         if(this.ds.getCount()==1){\r
215             this.refresh();\r
216         }else{\r
217             this.isUpdating = true;\r
218             Ext.grid.GroupingView.superclass.refreshRow.apply(this, arguments);\r
219             this.isUpdating = false;\r
220         }\r
221     },\r
222 \r
223     // private\r
224     beforeMenuShow : function(){\r
225         var item, items = this.hmenu.items, disabled = this.cm.config[this.hdCtxIndex].groupable === false;\r
226         if((item = items.get('groupBy'))){\r
227             item.setDisabled(disabled);\r
228         }\r
229         if((item = items.get('showGroups'))){\r
230             item.setDisabled(disabled);\r
231             item.setChecked(this.enableGrouping, true);\r
232         }\r
233     },\r
234 \r
235     // private\r
236     renderUI : function(){\r
237         Ext.grid.GroupingView.superclass.renderUI.call(this);\r
238         this.mainBody.on('mousedown', this.interceptMouse, this);\r
239 \r
240         if(this.enableGroupingMenu && this.hmenu){\r
241             this.hmenu.add('-',{\r
242                 itemId:'groupBy',\r
243                 text: this.groupByText,\r
244                 handler: this.onGroupByClick,\r
245                 scope: this,\r
246                 iconCls:'x-group-by-icon'\r
247             });\r
248             if(this.enableNoGroups){\r
249                 this.hmenu.add({\r
250                     itemId:'showGroups',\r
251                     text: this.showGroupsText,\r
252                     checked: true,\r
253                     checkHandler: this.onShowGroupsClick,\r
254                     scope: this\r
255                 });\r
256             }\r
257             this.hmenu.on('beforeshow', this.beforeMenuShow, this);\r
258         }\r
259     },\r
260 \r
261     processEvent: function(name, e){\r
262         var hd = e.getTarget('.x-grid-group-hd', this.mainBody);\r
263         if(hd){\r
264             // group value is at the end of the string\r
265             var field = this.getGroupField(),\r
266                 prefix = this.getPrefix(field),\r
267                 groupValue = hd.id.substring(prefix.length);\r
268 \r
269             // remove trailing '-hd'\r
270             groupValue = groupValue.substr(0, groupValue.length - 3);\r
271             if(groupValue){\r
272                 this.grid.fireEvent('group' + name, this.grid, field, groupValue, e);\r
273             }\r
274         }\r
275 \r
276     },\r
277 \r
278     // private\r
279     onGroupByClick : function(){\r
280         this.enableGrouping = true;\r
281         this.grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));\r
282         this.grid.fireEvent('groupchange', this, this.grid.store.getGroupState());\r
283         this.beforeMenuShow(); // Make sure the checkboxes get properly set when changing groups\r
284         this.refresh();\r
285     },\r
286 \r
287     // private\r
288     onShowGroupsClick : function(mi, checked){\r
289     this.enableGrouping = checked;\r
290         if(checked){\r
291             this.onGroupByClick();\r
292         }else{\r
293             this.grid.store.clearGrouping();\r
294             this.grid.fireEvent('groupchange', this, null);\r
295         }\r
296     },\r
297 \r
298     /**\r
299      * Toggle the group that contains the specific row.\r
300      * @param {Number} rowIndex The row inside the group\r
301      * @param {Boolean} expanded (optional)\r
302      */\r
303     toggleRowIndex : function(rowIndex, expanded){\r
304         if(!this.canGroup()){\r
305             return;\r
306         }\r
307         var row = this.getRow(rowIndex);\r
308         if(row){\r
309             this.toggleGroup(this.findGroup(row), expanded);\r
310         }\r
311     },\r
312 \r
313     /**\r
314      * Toggles the specified group if no value is passed, otherwise sets the expanded state of the group to the value passed.\r
315      * @param {String} groupId The groupId assigned to the group (see getGroupId)\r
316      * @param {Boolean} expanded (optional)\r
317      */\r
318     toggleGroup : function(group, expanded){\r
319         var gel = Ext.get(group);\r
320         expanded = Ext.isDefined(expanded) ? expanded : gel.hasClass('x-grid-group-collapsed');\r
321         if(this.state[gel.id] !== expanded){\r
322             this.grid.stopEditing(true);\r
323             this.state[gel.id] = expanded;\r
324             gel[expanded ? 'removeClass' : 'addClass']('x-grid-group-collapsed');\r
325         }\r
326     },\r
327 \r
328     /**\r
329      * Toggles all groups if no value is passed, otherwise sets the expanded state of all groups to the value passed.\r
330      * @param {Boolean} expanded (optional)\r
331      */\r
332     toggleAllGroups : function(expanded){\r
333         var groups = this.getGroups();\r
334         for(var i = 0, len = groups.length; i < len; i++){\r
335             this.toggleGroup(groups[i], expanded);\r
336         }\r
337     },\r
338 \r
339     /**\r
340      * Expands all grouped rows.\r
341      */\r
342     expandAllGroups : function(){\r
343         this.toggleAllGroups(true);\r
344     },\r
345 \r
346     /**\r
347      * Collapses all grouped rows.\r
348      */\r
349     collapseAllGroups : function(){\r
350         this.toggleAllGroups(false);\r
351     },\r
352 \r
353     // private\r
354     interceptMouse : function(e){\r
355         var hd = e.getTarget('.x-grid-group-hd', this.mainBody);\r
356         if(hd){\r
357             e.stopEvent();\r
358             this.toggleGroup(hd.parentNode);\r
359         }\r
360     },\r
361 \r
362     // private\r
363     getGroup : function(v, r, groupRenderer, rowIndex, colIndex, ds){\r
364         var g = groupRenderer ? groupRenderer(v, {}, r, rowIndex, colIndex, ds) : String(v);\r
365         if(g === '' || g === '&#160;'){\r
366             g = this.cm.config[colIndex].emptyGroupText || this.emptyGroupText;\r
367         }\r
368         return g;\r
369     },\r
370 \r
371     // private\r
372     getGroupField : function(){\r
373         return this.grid.store.getGroupState();\r
374     },\r
375 \r
376     // private\r
377     afterRender : function(){\r
378         if(!this.ds || !this.cm){\r
379             return;\r
380         }\r
381         Ext.grid.GroupingView.superclass.afterRender.call(this);\r
382         if(this.grid.deferRowRender){\r
383             this.updateGroupWidths();\r
384         }\r
385     },\r
386 \r
387     // private\r
388     renderRows : function(){\r
389         var groupField = this.getGroupField();\r
390         var eg = !!groupField;\r
391         // if they turned off grouping and the last grouped field is hidden\r
392         if(this.hideGroupedColumn) {\r
393             var colIndex = this.cm.findColumnIndex(groupField),\r
394                 hasLastGroupField = Ext.isDefined(this.lastGroupField);\r
395             if(!eg && hasLastGroupField){\r
396                 this.mainBody.update('');\r
397                 this.cm.setHidden(this.cm.findColumnIndex(this.lastGroupField), false);\r
398                 delete this.lastGroupField;\r
399             }else if (eg && !hasLastGroupField){\r
400                 this.lastGroupField = groupField;\r
401                 this.cm.setHidden(colIndex, true);\r
402             }else if (eg && hasLastGroupField && groupField !== this.lastGroupField) {\r
403                 this.mainBody.update('');\r
404                 var oldIndex = this.cm.findColumnIndex(this.lastGroupField);\r
405                 this.cm.setHidden(oldIndex, false);\r
406                 this.lastGroupField = groupField;\r
407                 this.cm.setHidden(colIndex, true);\r
408             }\r
409         }\r
410         return Ext.grid.GroupingView.superclass.renderRows.apply(\r
411                     this, arguments);\r
412     },\r
413 \r
414     // private\r
415     doRender : function(cs, rs, ds, startRow, colCount, stripe){\r
416         if(rs.length < 1){\r
417             return '';\r
418         }\r
419 \r
420         if(!this.canGroup() || this.isUpdating){\r
421             return Ext.grid.GroupingView.superclass.doRender.apply(\r
422                     this, arguments);\r
423         }\r
424 \r
425         var groupField = this.getGroupField(),\r
426             colIndex = this.cm.findColumnIndex(groupField),\r
427             g,\r
428             gstyle = 'width:' + this.getTotalWidth() + ';',\r
429             cfg = this.cm.config[colIndex],\r
430             groupRenderer = cfg.groupRenderer || cfg.renderer,\r
431             prefix = this.showGroupName ? (cfg.groupName || cfg.header)+': ' : '',\r
432             groups = [],\r
433             curGroup, i, len, gid;\r
434 \r
435         for(i = 0, len = rs.length; i < len; i++){\r
436             var rowIndex = startRow + i,\r
437                 r = rs[i],\r
438                 gvalue = r.data[groupField];\r
439 \r
440                 g = this.getGroup(gvalue, r, groupRenderer, rowIndex, colIndex, ds);\r
441             if(!curGroup || curGroup.group != g){\r
442                 gid = this.constructId(gvalue, groupField, colIndex);\r
443                 // if state is defined use it, however state is in terms of expanded\r
444                 // so negate it, otherwise use the default.\r
445                 this.state[gid] = !(Ext.isDefined(this.state[gid]) ? !this.state[gid] : this.startCollapsed);\r
446                 curGroup = {\r
447                     group: g,\r
448                     gvalue: gvalue,\r
449                     text: prefix + g,\r
450                     groupId: gid,\r
451                     startRow: rowIndex,\r
452                     rs: [r],\r
453                     cls: this.state[gid] ? '' : 'x-grid-group-collapsed',\r
454                     style: gstyle\r
455                 };\r
456                 groups.push(curGroup);\r
457             }else{\r
458                 curGroup.rs.push(r);\r
459             }\r
460             r._groupId = gid;\r
461         }\r
462 \r
463         var buf = [];\r
464         for(i = 0, len = groups.length; i < len; i++){\r
465             g = groups[i];\r
466             this.doGroupStart(buf, g, cs, ds, colCount);\r
467             buf[buf.length] = Ext.grid.GroupingView.superclass.doRender.call(\r
468                     this, cs, g.rs, ds, g.startRow, colCount, stripe);\r
469 \r
470             this.doGroupEnd(buf, g, cs, ds, colCount);\r
471         }\r
472         return buf.join('');\r
473     },\r
474 \r
475     /**\r
476      * Dynamically tries to determine the groupId of a specific value\r
477      * @param {String} value\r
478      * @return {String} The group id\r
479      */\r
480     getGroupId : function(value){\r
481         var field = this.getGroupField();\r
482         return this.constructId(value, field, this.cm.findColumnIndex(field));\r
483     },\r
484 \r
485     // private\r
486     constructId : function(value, field, idx){\r
487         var cfg = this.cm.config[idx],\r
488             groupRenderer = cfg.groupRenderer || cfg.renderer,\r
489             val = (this.groupMode == 'value') ? value : this.getGroup(value, {data:{}}, groupRenderer, 0, idx, this.ds);\r
490 \r
491         return this.getPrefix(field) + Ext.util.Format.htmlEncode(val);\r
492     },\r
493 \r
494     // private\r
495     canGroup  : function(){\r
496         return this.enableGrouping && !!this.getGroupField();\r
497     },\r
498 \r
499     // private\r
500     getPrefix: function(field){\r
501         return this.grid.getGridEl().id + '-gp-' + field + '-';\r
502     },\r
503 \r
504     // private\r
505     doGroupStart : function(buf, g, cs, ds, colCount){\r
506         buf[buf.length] = this.startGroup.apply(g);\r
507     },\r
508 \r
509     // private\r
510     doGroupEnd : function(buf, g, cs, ds, colCount){\r
511         buf[buf.length] = this.endGroup;\r
512     },\r
513 \r
514     // private\r
515     getRows : function(){\r
516         if(!this.canGroup()){\r
517             return Ext.grid.GroupingView.superclass.getRows.call(this);\r
518         }\r
519         var r = [];\r
520         var g, gs = this.getGroups();\r
521         for(var i = 0, len = gs.length; i < len; i++){\r
522             g = gs[i].childNodes[1].childNodes;\r
523             for(var j = 0, jlen = g.length; j < jlen; j++){\r
524                 r[r.length] = g[j];\r
525             }\r
526         }\r
527         return r;\r
528     },\r
529 \r
530     // private\r
531     updateGroupWidths : function(){\r
532         if(!this.canGroup() || !this.hasRows()){\r
533             return;\r
534         }\r
535         var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.getScrollOffset()) +'px';\r
536         var gs = this.getGroups();\r
537         for(var i = 0, len = gs.length; i < len; i++){\r
538             gs[i].firstChild.style.width = tw;\r
539         }\r
540     },\r
541 \r
542     // private\r
543     onColumnWidthUpdated : function(col, w, tw){\r
544         Ext.grid.GroupingView.superclass.onColumnWidthUpdated.call(this, col, w, tw);\r
545         this.updateGroupWidths();\r
546     },\r
547 \r
548     // private\r
549     onAllColumnWidthsUpdated : function(ws, tw){\r
550         Ext.grid.GroupingView.superclass.onAllColumnWidthsUpdated.call(this, ws, tw);\r
551         this.updateGroupWidths();\r
552     },\r
553 \r
554     // private\r
555     onColumnHiddenUpdated : function(col, hidden, tw){\r
556         Ext.grid.GroupingView.superclass.onColumnHiddenUpdated.call(this, col, hidden, tw);\r
557         this.updateGroupWidths();\r
558     },\r
559 \r
560     // private\r
561     onLayout : function(){\r
562         this.updateGroupWidths();\r
563     },\r
564 \r
565     // private\r
566     onBeforeRowSelect : function(sm, rowIndex){\r
567         this.toggleRowIndex(rowIndex, true);\r
568     }\r
569 });\r
570 // private\r
571 Ext.grid.GroupingView.GROUP_ID = 1000;