001: /*
002: * GWT-Ext Widget Library
003: * Copyright(c) 2007-2008, GWT-Ext.
004: * licensing@gwt-ext.com
005: *
006: * http://www.gwt-ext.com/license
007: */
008:
009: package com.gwtext.client.widgets.grid;
010:
011: import com.google.gwt.core.client.JavaScriptObject;
012: import com.google.gwt.user.client.Element;
013: import com.google.gwt.user.client.Timer;
014: import com.gwtext.client.core.Ext;
015: import com.gwtext.client.core.Function;
016: import com.gwtext.client.data.Store;
017: import com.gwtext.client.util.JavaScriptObjectHelper;
018: import com.gwtext.client.widgets.Panel;
019: import com.gwtext.client.widgets.grid.event.*;
020:
021: /**
022: * A Grid widget.
023: * <br/></br/>
024: * <b>Common Problems:</b>
025: * <ul>
026: * <li>Grid does not resize properly when going smaller: Setting overflow hidden on the container element will correct this</li>
027: * <li>If you get el.style[camel]= NaNpx or -2px or something related, be certain you have given your container element dimensions.
028: * The grid adapts to your container's size, if your container has no size defined then the results are unpredictable.</li>
029: * <li>Do not render the grid into an element with display:none. Try using visibility:hidden. Otherwise there is no way for
030: * the grid to calculate dimensions/offsets.</li>
031: * </ul>
032: *
033: * <br>
034: * CSS can be used to style or customize the behaviour of headers an cells.
035: * <br>
036: * For example, use this to wrap all cell contents globally
037: * <pre>
038: * .x-grid3-cell-inner {
039: * overflow: visible; white-space: normal !important;
040: * }
041: * </pre>
042: * To wrap cell contents on a certain table only, set an ID to the Grid panel (say company-grid) and then use the CSS
043: * <pre>
044: * #company-grid .x-grid3-cell-inner {
045: * overflow: visible; white-space: normal !important;
046: * }
047: * </pre>
048: * To wrap long header titles
049: * For all grids
050: * <pre>
051: * .x-grid3-hd-inner {
052: * overflow: visible; white-space: normal;
053: * }
054: * </pre>
055: *
056: * For specific grid
057: * <pre>
058: * #company-grid .x-grid3-hd-inner {
059: * overflow: visible; white-space: normal;
060: * }
061: * </pre>
062: *
063: * For specific column
064: * <pre>
065: * .x-grid3-hd-company {
066: * overflow: visible; white-space: normal !important;
067: * }
068: * </pre>
069: */
070: public class GridPanel extends Panel {
071:
072: private static JavaScriptObject configPrototype;
073:
074: static {
075: init();
076: }
077:
078: private static native void init()/*-{
079: var c = new $wnd.Ext.grid.GridPanel();
080: @com.gwtext.client.widgets.grid.GridPanel::configPrototype = c.initialConfig;
081: }-*/;
082:
083: protected JavaScriptObject getConfigPrototype() {
084: return configPrototype;
085: }
086:
087: public String getXType() {
088: return "grid";
089: }
090:
091: public GridPanel(JavaScriptObject jsObj) {
092: super (jsObj);
093: }
094:
095: public GridPanel() {
096: }
097:
098: /**
099: * Creates a new Grid.
100: *
101: * @param store the Grid's data store
102: * @param columnModel the Grid's column model
103: */
104: public GridPanel(Store store, ColumnModel columnModel) {
105: setStore(store);
106: setColumnModel(columnModel);
107: }
108:
109: /**
110: * Creates a new Grid.
111: *
112: * @param id the Grid ID
113: * @param width the Grid width
114: * @param height the Grid height
115: * @param store the Grid's data store
116: * @param columnModel the Grid's column model
117: */
118: public GridPanel(String id, int width, int height, Store store,
119: ColumnModel columnModel) {
120: setId(id);
121: setWidth(width);
122: setHeight(height);
123: setStore(store);
124: setColumnModel(columnModel);
125: }
126:
127: protected native JavaScriptObject create(JavaScriptObject configJS) /*-{
128: return new $wnd.Ext.grid.GridPanel(configJS);
129: }-*/;
130:
131: protected void initComponent() {
132: super .initComponent();
133: Store store = getStore();
134: if (store == null) {
135: error("A Store must be assigned to the GridPanel. See setStore(..)");
136: }
137: }
138:
139: /**
140: * Returns the grid's ColumnModel.
141: *
142: * @return the column model
143: */
144: public ColumnModel getColumnModel() {
145: return new ColumnModel(getColumnModel(getOrCreateJsObj()));
146: }
147:
148: private native JavaScriptObject getColumnModel(JavaScriptObject grid) /*-{
149: return grid.getColumnModel();
150: }-*/;
151:
152: /**
153: * Returns the Grid's Store
154: *
155: * @return the Grids Store
156: */
157: public Store getStore() {
158: JavaScriptObject storeJS = JavaScriptObjectHelper
159: .getAttributeAsJavaScriptObject(config, "store");
160: return storeJS == null ? null : new Store(storeJS);
161: }
162:
163: /**
164: * Called to get Grid's drag proxy text.
165: *
166: * @return the grids drag drop text
167: */
168: public native String getDragDropText() /*-{
169: var grid = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
170: return grid.getDragDropText();
171: }-*/;
172:
173: /**
174: * Sets the Grid's drag drop text
175: *
176: * @param text the drag drop text
177: */
178: public native void setDragDropText(String text) /*-{
179: var grid = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
180: grid.ddText = text;
181: }-*/;
182:
183: /**
184: * Returns the Grid's row selection model
185: *
186: * @return the selection model
187: */
188: public RowSelectionModel getSelectionModel() {
189: return new RowSelectionModel(
190: getSelectionModel(getOrCreateJsObj()));
191: }
192:
193: private native JavaScriptObject getSelectionModel(
194: JavaScriptObject grid) /*-{
195: return grid.getSelectionModel();
196: }-*/;
197:
198: /**
199: * Returns the grid's GridView object.
200: *
201: * @return grid view
202: */
203: public GridView getView() {
204: return new GridView(getView(getOrCreateJsObj()));
205: }
206:
207: private native JavaScriptObject getView(JavaScriptObject grid) /*-{
208: return grid.getView();
209: }-*/;
210:
211: /**
212: * Hides the specified column.
213: *
214: * @param colID the column ID
215: */
216: public void hideColumn(String colID) {
217: int colIndex = getColumnModel().getIndexById(colID);
218: if (colIndex != -1) {
219: hideColumn(colIndex);
220: }
221: }
222:
223: /**
224: * Hides the specified column.
225: *
226: * @param colIndex the column index
227: */
228: public void hideColumn(int colIndex) {
229: getColumnModel().setHidden(colIndex, true);
230: if (isRendered() && Ext.isIE()) {
231: Timer t = new Timer() {
232: public void run() {
233: getView().refresh();
234: getView().updateHeaderSortState();
235: }
236: };
237: t.schedule(10);
238: }
239: }
240:
241: /**
242: * Hides the column header of the grid.
243: */
244: public void hideColumnHeader() {
245: if (isRendered()) {
246: Element el = getEl().child("div[class=x-grid3-header]");
247: Ext.fly(el).setStyle("display", "none");
248: } else {
249: addListener("render", new Function() {
250: public void execute() {
251: hideColumnHeader();
252: }
253: });
254: }
255: }
256:
257: public native void render(JavaScriptObject grid) /*-{
258: grid.render();
259: }-*/;
260:
261: //http://extjs.com/forum/showthread.php?t=8694&highlight=grid+reconfigure
262: /**
263: * Reconfigures the grid to use a different Store and Column Model. The View will be bound to the new objects and refreshed.
264: *
265: * @param store the new Store
266: * @param columnModel the new ColumnModel
267: */
268: public native void reconfigure(Store store, ColumnModel columnModel) /*-{
269: var grid = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
270: var storeJS = store.@com.gwtext.client.core.JsObject::getJsObj()();
271: var columnModelJS = columnModel.@com.gwtext.client.core.JsObject::getJsObj()();
272: grid.reconfigure(storeJS, columnModelJS);
273: }-*/;
274:
275: /**
276: * Sets the load mask message for the grid.
277: *
278: * @param message the load mask text
279: */
280: public native void setLoadMask(String message)/*-{
281: var grid = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
282: grid.loadMask.msg = message;
283: }-*/;
284:
285: /**
286: * Show the specified column.
287: *
288: * @param colID the column ID
289: */
290: public void showColumn(String colID) {
291: int colIndex = getColumnModel().getIndexById(colID);
292: if (colIndex != -1) {
293: showColumn(colIndex);
294: }
295: }
296:
297: /**
298: * Shows the specified column.
299: *
300: * @param colIndex the column index
301: */
302: public void showColumn(int colIndex) {
303: getColumnModel().setHidden(colIndex, false);
304: if (Ext.isIE()) {
305: Timer t = new Timer() {
306: public void run() {
307: getView().refresh();
308: getView().updateHeaderSortState();
309: }
310: };
311: t.schedule(10);
312: }
313: }
314:
315: /**
316: * Add a Grid Cell listener.
317: *
318: * @param listener the listener
319: */
320: public native void addGridCellListener(GridCellListener listener) /*-{
321: var gridJ = this;
322:
323: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('cellclick',
324: function(self, rowIndex, colIndex, event) {
325: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
326: listener.@com.gwtext.client.widgets.grid.event.GridCellListener::onCellClick(Lcom/gwtext/client/widgets/grid/GridPanel;IILcom/gwtext/client/core/EventObject;)(gridJ, rowIndex, colIndex, e);
327: }
328: );
329:
330: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('cellcontextmenu',
331: function(self, rowIndex, colIndex, event) {
332: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
333: listener.@com.gwtext.client.widgets.grid.event.GridCellListener::onCellContextMenu(Lcom/gwtext/client/widgets/grid/GridPanel;IILcom/gwtext/client/core/EventObject;)(gridJ, rowIndex, colIndex, e);
334: }
335: );
336:
337: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('celldblclick',
338: function(self, rowIndex, colIndex, event) {
339: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
340: listener.@com.gwtext.client.widgets.grid.event.GridCellListener::onCellDblClick(Lcom/gwtext/client/widgets/grid/GridPanel;IILcom/gwtext/client/core/EventObject;)(gridJ, rowIndex, colIndex, e);
341: }
342: );
343: }-*/;
344:
345: /**
346: * Add a Grid Column listener.
347: *
348: * @param listener the listener
349: */
350: public native void addGridColumnListener(GridColumnListener listener) /*-{
351:
352: var gridJ = this;
353:
354: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('columnmove',
355: function(oldIndex, newIndex) {
356: listener.@com.gwtext.client.widgets.grid.event.GridColumnListener::onColumnMove(Lcom/gwtext/client/widgets/grid/GridPanel;II)(gridJ, oldIndex, newIndex);
357: }
358: );
359: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('columnresize',
360: function(colIndex, newSize) {
361: listener.@com.gwtext.client.widgets.grid.event.GridColumnListener::onColumnResize(Lcom/gwtext/client/widgets/grid/GridPanel;II)(gridJ, colIndex, newSize);
362: }
363: );
364: }-*/;
365:
366: /**
367: * Add a Grid Header listener.
368: *
369: * @param listener the listener
370: */
371: public native void addGridHeaderListener(GridHeaderListener listener) /*-{
372: var gridJ = this;
373:
374: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('headerclick',
375: function(g, colIndex, event) {
376: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
377: listener.@com.gwtext.client.widgets.grid.event.GridHeaderListener::onHeaderClick(Lcom/gwtext/client/widgets/grid/GridPanel;ILcom/gwtext/client/core/EventObject;)(gridJ, colIndex, e);
378: }
379: );
380: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('headercontextmenu',
381: function(g, colIndex, event) {
382: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
383: listener.@com.gwtext.client.widgets.grid.event.GridHeaderListener::onHeaderContextMenu(Lcom/gwtext/client/widgets/grid/GridPanel;ILcom/gwtext/client/core/EventObject;)(gridJ, colIndex, e);
384: }
385: );
386: //todo check signature as it currently has rowindex
387: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('headerdblclick',
388: function(g, colIndex, event) {
389: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
390: listener.@com.gwtext.client.widgets.grid.event.GridHeaderListener::onHeaderDblClick(Lcom/gwtext/client/widgets/grid/GridPanel;ILcom/gwtext/client/core/EventObject;)(gridJ, colIndex, e);
391: }
392: );
393: }-*/;
394:
395: /**
396: * Add a Grid Cell listener.
397: *
398: * @param listener the listener
399: */
400: public native void addGridListener(GridListener listener) /*-{
401: var gridJ = this;
402:
403: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('bodyscroll',
404: function(scrollLeft, scrollTop) {
405: listener.@com.gwtext.client.widgets.grid.event.GridListener::onBodyScroll(II)(scrollLeft, scrollTop);
406: }
407: );
408: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('click',
409: function(event) {
410: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
411: listener.@com.gwtext.client.widgets.grid.event.GridListener::onClick(Lcom/gwtext/client/core/EventObject;)(e);
412: }
413: );
414: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('contextmenu',
415: function(event) {
416: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
417: listener.@com.gwtext.client.widgets.grid.event.GridListener::onContextMenu(Lcom/gwtext/client/core/EventObject;)(e);
418: }
419: );
420: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('dblclick',
421: function(event) {
422: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
423: listener.@com.gwtext.client.widgets.grid.event.GridListener::onDblClick(Lcom/gwtext/client/core/EventObject;)(e);
424: }
425: );
426:
427: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('keydown',
428: function(event) {
429: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
430: listener.@com.gwtext.client.widgets.grid.event.GridListener::onKeyDown(Lcom/gwtext/client/core/EventObject;)(e);
431: }
432: );
433:
434: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('keypress',
435: function(event) {
436: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
437: listener.@com.gwtext.client.widgets.grid.event.GridListener::onKeyPress(Lcom/gwtext/client/core/EventObject;)(e);
438: }
439: );
440:
441: }-*/;
442:
443: /**
444: * Add a Grid mouse listener.
445: *
446: * @param listener the listener
447: */
448: public native void addGridMouseListener(GridMouseListener listener) /*-{
449: var gridJ = this;
450:
451: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('mousedown',
452: function(event) {
453: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
454: listener.@com.gwtext.client.widgets.grid.event.GridMouseListener::onMouseDown(Lcom/gwtext/client/core/EventObject;)(e);
455: }
456: );
457: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('mouseout',
458: function(event) {
459: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
460: listener.@com.gwtext.client.widgets.grid.event.GridMouseListener::onMouseOut(Lcom/gwtext/client/core/EventObject;)(e);
461: }
462: );
463: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('mouseover',
464: function(event) {
465: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
466: listener.@com.gwtext.client.widgets.grid.event.GridMouseListener::onMouseOver(Lcom/gwtext/client/core/EventObject;)(e);
467: }
468: );
469:
470: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('mouseup',
471: function(event) {
472: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
473: listener.@com.gwtext.client.widgets.grid.event.GridMouseListener::onMouseUp(Lcom/gwtext/client/core/EventObject;)(e);
474: }
475: );
476: }-*/;
477:
478: /**
479: * Add a Grid row listener.
480: *
481: * @param listener the listener
482: */
483: public native void addGridRowListener(GridRowListener listener) /*-{
484: var gridJ = this;
485:
486: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('rowclick',
487: function(source, rowIndex, event) {
488: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
489: listener.@com.gwtext.client.widgets.grid.event.GridRowListener::onRowClick(Lcom/gwtext/client/widgets/grid/GridPanel;ILcom/gwtext/client/core/EventObject;)(gridJ, rowIndex, e);
490: }
491: );
492:
493: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('rowdblclick',
494: function(source, rowIndex, event) {
495: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
496: listener.@com.gwtext.client.widgets.grid.event.GridRowListener::onRowDblClick(Lcom/gwtext/client/widgets/grid/GridPanel;ILcom/gwtext/client/core/EventObject;)(gridJ, rowIndex, e);
497: }
498: );
499:
500: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('rowcontextmenu',
501: function(source, rowIndex, event) {
502: var e = @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
503: listener.@com.gwtext.client.widgets.grid.event.GridRowListener::onRowContextMenu(Lcom/gwtext/client/widgets/grid/GridPanel;ILcom/gwtext/client/core/EventObject;)(gridJ, rowIndex, e);
504: }
505: );
506: }-*/;
507:
508: // --- config properties ---
509:
510: /**
511: * The DD group this GridPanel belongs to (defaults to 'GridDD').
512: *
513: * @param ddGroup the DD group
514: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
515: */
516: public void setDdGroup(String ddGroup) throws IllegalStateException {
517: setAttribute("ddGroup", ddGroup, true);
518: }
519:
520: /**
521: * The minimum width a column can be resized to. Default is 25.
522: *
523: * @param minColumnWidth the min column width
524: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
525: */
526: public void setMinColumnWidth(int minColumnWidth)
527: throws IllegalStateException {
528: setAttribute("minColumnWidth", minColumnWidth, true);
529: }
530:
531: /**
532: * True to autoSize the grid when the window resizes. Default is true.
533: *
534: * @param monitorWindowResize true to monitor window resize
535: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
536: */
537: public void setMonitorWindowResize(boolean monitorWindowResize)
538: throws IllegalStateException {
539: setAttribute("monitorWindowResize", monitorWindowResize, true);
540: }
541:
542: /**
543: * If autoSizeColumns is on, maxRowsToMeasure can be used to limit the number of rows measured to get a columns size.
544: * Default is 0 (all rows).
545: *
546: * @param maxRowsToMeasure max rows to measure
547: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
548: */
549: public void setMaxRowsToMeasure(int maxRowsToMeasure)
550: throws IllegalStateException {
551: setAttribute("maxRowsToMeasure", maxRowsToMeasure, true);
552: }
553:
554: /**
555: * True to highlight rows when the mouse is over. Default is true.
556: *
557: * @param trackMouseOver true to highlight rows when mouse over
558: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
559: */
560: public void setTrackMouseOver(boolean trackMouseOver)
561: throws IllegalStateException {
562: setAttribute("trackMouseOver", trackMouseOver, true);
563: }
564:
565: /**
566: * True to enable Grid context menus.
567: *
568: * @param enableCtxMenu true to enable context menu
569: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
570: */
571: public void setEnableCtxMenu(boolean enableCtxMenu)
572: throws IllegalStateException {
573: setAttribute("enableCtxMenu", enableCtxMenu, true);
574: }
575:
576: /**
577: * True to enable column resize.
578: *
579: * @param enableColumnResize true to enable column resize
580: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
581: */
582: public void setEnableColumnResize(boolean enableColumnResize)
583: throws IllegalStateException {
584: setAttribute("enableColumnResize", enableColumnResize, true);
585: }
586:
587: //http://extjs.com/forum/showthread.php?p=43678#post43678
588: /**
589: * True to enable drag and drop of rows. Default is false.
590: *
591: * @param enableDragDrop true to enable drag drop of rows
592: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
593: */
594: public void setEnableDragDrop(boolean enableDragDrop)
595: throws IllegalStateException {
596: setAttribute("enableDragDrop", enableDragDrop, true);
597: }
598:
599: /**
600: * True to enable drag and drop reorder of columns. Default is true.
601: *
602: * @param enableColumnMove true to enable column move
603: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
604: */
605: public void setEnableColumnMove(boolean enableColumnMove)
606: throws IllegalStateException {
607: setAttribute("enableColumnMove", enableColumnMove, true);
608: }
609:
610: /**
611: * True to enable hiding of columns with the header context menu. Default is true
612: *
613: * @param enableColumnHide true to enable column hide
614: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
615: */
616: public void setEnableColumnHide(boolean enableColumnHide)
617: throws IllegalStateException {
618: setAttribute("enableColumnHide", enableColumnHide, true);
619: }
620:
621: /**
622: * True to stripe the rows. Default is true.
623: *
624: * @param stripeRows true to stripe rows
625: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
626: */
627: public void setStripeRows(boolean stripeRows)
628: throws IllegalStateException {
629: setAttribute("stripeRows", stripeRows, true);
630: }
631:
632: /**
633: * Set the GridPanel's selection model.
634: *
635: * @param selectionModel the selection model/
636: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
637: */
638: public void setSelectionModel(AbstractSelectionModel selectionModel)
639: throws IllegalStateException {
640: setAttribute("sm", selectionModel.getJsObj(), true);
641: }
642:
643: /**
644: * True to fit the height of the grid container to the height of the data. Default is false.
645: *
646: * @param autoHeight true to fit the height of the grid container to the height of the data
647: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
648: */
649: public void setAutoHeight(boolean autoHeight)
650: throws IllegalStateException {
651: setAttribute("autoHeight", autoHeight, true);
652: }
653:
654: /**
655: * The id of a column in this grid that should expand to fill unused space.
656: * This id can not be 0. Default is false. <br>
657: * <b>Note : You must pass the ID of the ColumnConfig, and not the dataIndex of the corresponding ColumnConfig.</b>
658: *
659: * @param autoExpandColumn the column id
660: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
661: * @see com.gwtext.client.widgets.grid.ColumnConfig#setId(String)
662: */
663: public void setAutoExpandColumn(String autoExpandColumn)
664: throws IllegalStateException {
665: setAttribute("autoExpandColumn", autoExpandColumn, true);
666: }
667:
668: /**
669: * The id of a column in this grid that should expand to fill unused space. This id can not be 0.
670: * Default is false.
671: *
672: * @param autoExpandColumn the column id
673: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
674: */
675: public void setAutoExpandColumn(int autoExpandColumn)
676: throws IllegalStateException {
677: setAttribute("autoExpandColumn", autoExpandColumn, true);
678: }
679:
680: /**
681: * The minimum width the autoExpandColumn can have (if enabled). Default is 50.
682: *
683: * @param autoExpandMin the min expand value
684: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
685: */
686: public void setAutoExpandMin(int autoExpandMin)
687: throws IllegalStateException {
688: setAttribute("autoExpandMin", autoExpandMin, true);
689: }
690:
691: /**
692: * The maximum width the autoExpandColumn can have (if enabled). Default is 1000.
693: *
694: * @param autoExpandMax the max expand value
695: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
696: */
697: public void setAutoExpandMax(int autoExpandMax)
698: throws IllegalStateException {
699: setAttribute("autoExpandMax", autoExpandMax, true);
700: }
701:
702: /**
703: * Hides the column header of the grid if passed true.
704: *
705: * @param hideColumnHeader true to hide the column headers
706: */
707: public void setHideColumnHeader(boolean hideColumnHeader) {
708: if (hideColumnHeader) {
709: hideColumnHeader();
710: }
711: }
712:
713: /**
714: * Sets the {@link GridView} used by the grid.
715: *
716: * @param view the grid view
717: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
718: */
719: public void setView(GridView view) throws IllegalStateException {
720: setAttribute("view", view.getJsObj(), true);
721: }
722:
723: /**
724: * True to mask the grid while loading. Default is false.
725: *
726: * @param loadMask true to mask grid
727: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
728: */
729: public void setLoadMask(boolean loadMask)
730: throws IllegalStateException {
731: setAttribute("loadMask", loadMask, true);
732: }
733:
734: /**
735: * Sets the {@link com.gwtext.client.widgets.LoadMask} to mask the grid while loading. Default is disable masking.
736: *
737: * @param message the load mask message
738: * @param messageCls the load mask message CSS class
739: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
740: */
741: public void setLoadMask(String message, String messageCls)
742: throws IllegalStateException {
743: JavaScriptObject config = JavaScriptObjectHelper.createObject();
744: JavaScriptObjectHelper.setAttribute(config, "msg", message);
745: JavaScriptObjectHelper.setAttribute(config, "msgCls",
746: messageCls);
747: setAttribute("loadMask", config, true);
748:
749: }
750:
751: /**
752: * The Store the grid should use as its data source (required).
753: *
754: * @param store the store
755: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
756: */
757: public void setStore(Store store) throws IllegalStateException {
758: setAttribute("store", store.getJsObj(), true);
759: }
760:
761: /**
762: * The {@link ColumnModel} to use when rendering the grid (required).
763: *
764: * @param columnModel the grids column model
765: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
766: */
767: public void setColumnModel(ColumnModel columnModel)
768: throws IllegalStateException {
769: setAttribute("cm", columnModel.getJsObj(), true);
770: }
771:
772: /**
773: * True to stripe the rows. Default is false.
774: *
775: * @param stripeRows true to stripe the rows. Default is false.
776: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
777: */
778: public void stripeRows(boolean stripeRows)
779: throws IllegalStateException {
780: setAttribute("stripeRows", stripeRows, true);
781: }
782: }
|