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: package com.gwtext.client.widgets;
009:
010: import com.google.gwt.core.client.JavaScriptObject;
011: import com.google.gwt.user.client.Element;
012: import com.gwtext.client.core.GenericConfig;
013: import com.gwtext.client.core.XTemplate;
014: import com.gwtext.client.data.Record;
015: import com.gwtext.client.data.Store;
016: import com.gwtext.client.widgets.event.DataViewListener;
017:
018: /**
019: * A mechanism for displaying data using custom layout templates and formatting. DataView uses {@link XTemplate} as its internal
020: * templating mechanisma, and is bound to an {@link Store} so that as the data in the store changes the view is automatically
021: * updated to reflect the changes. The view also provides built-in behavior for many common events that can occur for its contained
022: * items including click, doubleclick, mouseover, mouseout, etc. as well as a built-in selection model.
023: *
024: * An itemSelector which is passed to the constructor is used to determine what nodes it will be working with.
025: *
026: * The example below binds a DataView to a Store and renders it into a {@link Panel}.
027: *
028: * <pre>
029: * <code>
030: *
031: * // data here is Object[][] of local data.
032: * MemoryProxy dataProxy = new MemoryProxy(getData());
033: * ArrayReader reader = new ArrayReader(new RecordDef(new FieldDef[]{
034: * new StringFieldDef("name"),
035: * new IntegerFieldDef("size"),
036: * new DateFieldDef("lastmod", "timestamp"),
037: * new StringFieldDef("url")}));
038: *
039: * Store store = new Store(dataProxy, reader);
040: * store.load();
041: *
042: * XTemplate template = new XTemplate(new String[]{
043: * "<tpl for='.'>",
044: * "<div class='thumb-wrap' id='{name}'>",
045: * "<div class='thumb'><img src='{url}' title='{name}'></div>",
046: * "<span class='x-editable'>{shortName}</span></div>",
047: * "</tpl>",
048: * "<div class='x-clear'></div>"});
049: *
050: * Panel panel = new Panel();
051: * panel.setId("images-view");
052: * panel.setFrame(true);
053: * panel.setAutoHeight(true);
054: * panel.setCollapsible(true);
055: * panel.setLayout(new FitLayout());
056: * panel.setTitle("Simple DataView with editable labels, multi and drag selection");
057: *
058: * //pre process the data from te store before passing it to the DataView
059: * DataView dataView = new DataView("div.thumb-wrap") {
060: * public void prepareData(Data data) {
061: * data.setProperty("shortName", Format.ellipsis(data.getProperty("name"), 15));
062: * } };
063: *
064: *
065: * dataView.setStore(store);
066: * dataView.setTpl(template);
067: * dataView.setAutoHeight(true);
068: * dataView.setMultiSelect(true);
069: * dataView.setOverCls("x-view-over");
070: * dataView.setEmptyText("No Images to display");
071: *
072: * panel.add(dataView);
073: * RootPanel.get().add(panel);
074: * </code>
075: * </pre>
076: *
077: */
078: public class DataView extends BoxComponent {
079: static {
080: init();
081: }
082:
083: private static native void init()/*-{
084: //var c = new $wnd.Ext.Component();
085: //@com.gwtext.client.widgets.Component::configPrototype = c.initialConfig;
086:
087: $wnd.Ext.DataView.prototype.prepareData=function(data) {
088: var compJ = this.__compJ;
089: if(compJ != null) {
090: var dataJ = @com.gwtext.client.widgets.DataView$Data::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(data);
091: compJ.@com.gwtext.client.widgets.DataView::prepareData(Lcom/gwtext/client/widgets/DataView$Data;)(dataJ);
092: return data;
093: } else {
094: return data;
095: }
096: };
097: }-*/;
098:
099: /**
100: * Create a new DataView.
101: *
102: * @param itemSelector a CSS selector in any format supported by {@link com.gwtext.client.core.DomQuery} that will be used to determine
103: * what nodes this DataView will be working with.
104: */
105: public DataView(String itemSelector) {
106: setItemSelector(itemSelector);
107: }
108:
109: public DataView(JavaScriptObject jsObj) {
110: super (jsObj);
111: }
112:
113: public String getXType() {
114: return "dataview";
115: }
116:
117: protected native JavaScriptObject create(JavaScriptObject config) /*-{
118: return new $wnd.Ext.DataView(config);
119: }-*/;
120:
121: /**
122: * This method that can be overridden to provide custom formatting for the data that is sent to the template for each node.
123: * Data can be retried by name for lookup and new fields / value can be added to it/
124: *
125: * @param data the view data
126: */
127: public void prepareData(Data data) {
128: }
129:
130: /**
131: * Clears all selections.
132: */
133: public native void clearSelections() /*-{
134: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
135: dv.clearSelections();
136: }-*/;
137:
138: /**
139: * Clears all selections.
140: *
141: * @param suppressEvent true to prevent firing of the selectionchange event
142: */
143: public native void clearSelections(boolean suppressEvent) /*-{
144: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
145: dv.clearSelections(suppressEvent);
146: }-*/;
147:
148: /**
149: * Deselects a node.
150: *
151: * @param element the node to delselect
152: */
153: public native void deselect(Element element) /*-{
154: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
155: dv.deselect(element);
156: }-*/;
157:
158: /**
159: * Deselects a node.
160: *
161: * @param nodeIndex index of node to deselect
162: */
163: public native void deselect(int nodeIndex) /*-{
164: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
165: dv.deselect(nodeIndex);
166: }-*/;
167:
168: /**
169: * Returns the template node the passed child belongs to, or null if it doesn't belong to one.
170: *
171: * @return template node the child belongs to
172: */
173: public native Element findItemFromChild() /*-{
174: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
175: var item = dv.findItemFromChild();
176: return item === undefined ? null : item;
177: }-*/;
178:
179: /**
180: * Gets a template node.
181: *
182: * @param nodeID the id of a template node
183: * @return the node or null if it wasn't found
184: */
185: public native Element getNode(String nodeID) /*-{
186: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
187: var node = dv.getNode(nodeID);
188: return node === undefined ? null : node;
189: }-*/;
190:
191: /**
192: * Gets a template node.
193: *
194: * @param nodeIndex the index of a template node
195: * @return the node or null if it wasn't found
196: */
197: public native Element getNode(int nodeIndex) /*-{
198: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
199: var node = dv.getNode(nodeIndex);
200: return node === undefined ? null : node;
201: }-*/;
202:
203: /**
204: * Gets a range nodes.
205: *
206: * @param start the index of the first node in the range
207: * @param end the index of the last node in the range
208: * @return an array of nodes
209: */
210: public native Element[] getNodes(int start, int end) /*-{
211: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
212: var nodes = dv.getNodes(start, end);
213: return @com.gwtext.client.util.JavaScriptObjectHelper::toElementArray(Lcom/google/gwt/core/client/JavaScriptObject;)(nodes);
214: }-*/;
215:
216: /**
217: * Gets a record from a node.
218: *
219: * @param node The node to evaluate
220: * @return the Record
221: */
222: public native Record getRecord(Element node) /*-{
223: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
224: var record = dv.getRecord(node);
225: return record == null || record === undefined ? null : @com.gwtext.client.data.Record::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(record);
226: }-*/;
227:
228: /**
229: * Gets the indexes of the selected nodes.
230: *
231: * @return an array of numeric indexes
232: */
233: public native int[] getSelectedIndexes() /*-{
234: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
235: var indexes = dv.getSelectedIndexes();
236: return @com.gwtext.client.util.JavaScriptObjectHelper::convertToJavaScriptArray([I)(indexes);
237: }-*/;
238:
239: /**
240: * Gets an array of the selected records.
241: *
242: * @return an array of Records
243: */
244: public native Record[] getSelectedRecords() /*-{
245: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
246: var records = dv.getSelectedRecords();
247: return @com.gwtext.client.data.Store::convertFromNativeRecordsArray(Lcom/google/gwt/core/client/JavaScriptObject;)(records);
248: }-*/;
249:
250: /**
251: * Gets the number of selected nodes.
252: *
253: * @return the node count
254: */
255: public native int getSelectionCount() /*-{
256: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
257: return dv.getSelectionCount();
258: }-*/;
259:
260: /**
261: * Finds the index of the passed node.
262: *
263: * @param element the node
264: * @return The index of the node or -1
265: */
266: public native int indexOf(Element element) /*-{
267: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
268: return dv.indexOf(element);
269: }-*/;
270:
271: /**
272: * Finds the index of the passed node.
273: *
274: * @param nodeID the node ID
275: * @return The index of the node or -1
276: */
277: public native int indexOf(String nodeID) /*-{
278: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
279: return dv.indexOf(nodeID);
280: }-*/;
281:
282: /**
283: * Finds the index of the passed node.
284: *
285: * @param nodeIndex the node index
286: * @return The index of the node or -1
287: */
288: public native int indexOf(int nodeIndex) /*-{
289: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
290: return dv.indexOf(nodeIndex);
291: }-*/;
292:
293: /**
294: * Returns true if the passed node is selected, else false.
295: *
296: * @param element the node
297: * @return true if selected
298: */
299: public native boolean isSelected(Element element) /*-{
300: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
301: return dv.isSelected(element);
302: }-*/;
303:
304: /**
305: * Returns true if the passed node is selected, else false.
306: *
307: * @param nodeIndex the node index
308: * @return true if selected
309: */
310: public native boolean isSelected(int nodeIndex) /*-{
311: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
312: return dv.isSelected(nodeIndex);
313: }-*/;
314:
315: //TODO ext 2.0 prepareData
316:
317: /**
318: * Refreshes the view by reloading the data from the store and re-rendering the template.
319: */
320: public native void refresh() /*-{
321: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
322: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
323: dv.refresh();
324: }
325: }-*/;
326:
327: /**
328: * Refreshes an individual node's data from the store.
329: *
330: * @param nodeIndex the node index
331: */
332: public native void refreshNode(int nodeIndex) /*-{
333: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
334: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
335: dv.refreshNode(nodeIndex);
336: }
337: }-*/;
338:
339: /**
340: * Selectsthe node.
341: *
342: * @param node the noed
343: */
344: public native void select(Element node) /*-{
345: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
346: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
347: dv.select(node);
348: }
349: }-*/;
350:
351: /**
352: * Selects the node.
353: *
354: * @param node the node
355: * @param keepExisting true to keep existing selections
356: * @param suppressEvent true to skip firing of the selectionchange vent
357: */
358: public native void select(Element node, boolean keepExisting,
359: boolean suppressEvent) /*-{
360: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
361: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
362: dv.select(node, keepExisting, suppressEvent);
363: }
364: }-*/;
365:
366: /**
367: * Selects the node.
368: *
369: * @param nodeIndex the node index
370: */
371: public native void select(int nodeIndex) /*-{
372: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
373: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
374: dv.select(nodeIndex);
375: }
376: }-*/;
377:
378: /**
379: * Selects the node.
380: *
381: * @param nodeIndex the node index
382: * @param keepExisting true to keep existing selections
383: * @param suppressEvent true to skip firing of the selectionchange event
384: */
385: public native void select(int nodeIndex, boolean keepExisting,
386: boolean suppressEvent) /*-{
387: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
388: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
389: dv.select(nodeIndex, keepExisting, suppressEvent);
390: }
391: }-*/;
392:
393: /**
394: * Selects a set of nodes.
395: *
396: * @param nodeIndexes the node indexes
397: */
398: public native void select(int[] nodeIndexes) /*-{
399: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
400: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
401: var nodeIndexesJS = @com.gwtext.client.util.JavaScriptObjectHelper::convertToJavaScriptArray([I)(nodeIndexes);
402: dv.select(nodeIndexesJS);
403: }
404: }-*/;
405:
406: /**
407: * Selects a set of nodes.
408: *
409: * @param nodeIndexes the node indexes
410: * @param keepExisting true to keep existing selections
411: * @param suppressEvent true to skip firing of the selectionchange event
412: */
413: public native void select(int[] nodeIndexes, boolean keepExisting,
414: boolean suppressEvent) /*-{
415: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
416: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
417: var nodeIndexesJS = @com.gwtext.client.util.JavaScriptObjectHelper::convertToJavaScriptArray([I)(nodeIndexes);
418: dv.select(nodeIndexesJS, keepExisting, suppressEvent);
419: }
420: }-*/;
421:
422: /**
423: * Selects a set of nodes.
424: *
425: * @param nodeIDs the node ID's
426: */
427: public native void select(String[] nodeIDs) /*-{
428: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
429: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
430: var nodeIDsJS = @com.gwtext.client.util.JavaScriptObjectHelper::convertToJavaScriptArray([Ljava/lang/Object;)(nodeIDs);
431: dv.select(nodeIDsJS);
432: }
433: }-*/;
434:
435: /**
436: * Selects a set of nodes.
437: *
438: * @param nodeIDs the node ID's
439: * @param keepExisting true to keep existing selections
440: * @param suppressEvent true to skip firing of the selectionchange event
441: */
442: public native void select(String[] nodeIDs, boolean keepExisting,
443: boolean suppressEvent) /*-{
444: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
445: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
446: var nodeIDsJS = @com.gwtext.client.util.JavaScriptObjectHelper::convertToJavaScriptArray([Ljava/lang/Object;)(nodeIDs);
447: dv.select(nodeIDsJS, keepExisting, suppressEvent);
448: }
449: }-*/;
450:
451: /**
452: * Selects a range of nodes. All nodes between start and end are selected.
453: *
454: * @param start The index of the first node in the range
455: * @param end The index of the last node in the range
456: */
457: public native void selectRange(int start, int end) /*-{
458: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
459: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
460: dv.selectRange(start, end);
461: }
462: }-*/;
463:
464: /**
465: * Selects a range of nodes. All nodes between start and end are selected.
466: *
467: * @param start The index of the first node in the range
468: * @param end The index of the last node in the range
469: * @param keepExisting true to retain existing selections
470: */
471: public native void selectRange(int start, int end,
472: boolean keepExisting) /*-{
473: if(this.@com.gwtext.client.widgets.Component::isRendered()()) {
474: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
475: dv.selectRange(start, end, keepExisting);
476: }
477: }-*/;
478:
479: public native void addListener(DataViewListener listener)/*-{
480: this.@com.gwtext.client.widgets.BoxComponent::addListener(Lcom/gwtext/client/widgets/event/BoxComponentListener;)(listener);
481: var dvJ = this;
482:
483: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforeclick',
484: function(source, index, node, event) {
485: var e = (event === undefined || event == null) ? null : @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
486: return listener.@com.gwtext.client.widgets.event.DataViewListener::doBeforeClick(Lcom/gwtext/client/widgets/DataView;ILcom/google/gwt/user/client/Element;Lcom/gwtext/client/core/EventObject;)(dvJ, index, node, e);
487: }
488: );
489:
490: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('beforeselect',
491: function(source, node, selections) {
492: var selectionsJ = @com.gwtext.client.util.JavaScriptObjectHelper::toElementArray(Lcom/google/gwt/core/client/JavaScriptObject;)(selections);
493: return listener.@com.gwtext.client.widgets.event.DataViewListener::doBeforeSelect(Lcom/gwtext/client/widgets/DataView;Lcom/google/gwt/user/client/Element;[Lcom/google/gwt/user/client/Element;)(dvJ, node, selectionsJ);
494: }
495: );
496:
497: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('click',
498: function(source, index, node, event) {
499: var e = (event === undefined || event == null) ? null : @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
500: listener.@com.gwtext.client.widgets.event.DataViewListener::onClick(Lcom/gwtext/client/widgets/DataView;ILcom/google/gwt/user/client/Element;Lcom/gwtext/client/core/EventObject;)(dvJ, index, node, e);
501: }
502: );
503:
504: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('containerclick',
505: function(source, event) {
506: var e = (event === undefined || event == null) ? null : @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
507: listener.@com.gwtext.client.widgets.event.DataViewListener::onContainerClick(Lcom/gwtext/client/widgets/DataView;Lcom/gwtext/client/core/EventObject;)(dvJ, e);
508: }
509: );
510:
511: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('contextmenu',
512: function(source, index, node, event) {
513: var e = (event === undefined || event == null) ? null : @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
514: listener.@com.gwtext.client.widgets.event.DataViewListener::onContextMenu(Lcom/gwtext/client/widgets/DataView;ILcom/google/gwt/user/client/Element;Lcom/gwtext/client/core/EventObject;)(dvJ, index, node, e);
515: }
516: );
517:
518: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('dblclick',
519: function(source, index, node, event) {
520: var e = (event === undefined || event == null) ? null : @com.gwtext.client.core.EventObject::instance(Lcom/google/gwt/core/client/JavaScriptObject;)(event);
521: listener.@com.gwtext.client.widgets.event.DataViewListener::onDblClick(Lcom/gwtext/client/widgets/DataView;ILcom/google/gwt/user/client/Element;Lcom/gwtext/client/core/EventObject;)(dvJ, index, node, e);
522: }
523: );
524:
525: this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('selectionchange',
526: function(source, selections) {
527: var selectionsJ = @com.gwtext.client.util.JavaScriptObjectHelper::toElementArray(Lcom/google/gwt/core/client/JavaScriptObject;)(selections);
528: listener.@com.gwtext.client.widgets.event.DataViewListener::onSelectionChange(Lcom/gwtext/client/widgets/DataView;[Lcom/google/gwt/user/client/Element;)(dvJ, selectionsJ);
529: }
530: );
531:
532: }-*/;
533:
534: //config
535: /**
536: * The text to display in the view when there is no data to display (defaults to '').
537: *
538: * @param emptyText the empty text
539: */
540: public void setEmptyText(String emptyText) {
541: setAttribute("emptyText", emptyText, true, true);
542: }
543:
544: /**
545: * A CSS selector in any format supported by {@link com.gwtext.client.core.DomQuery} that will be used to determine
546: * what nodes this DataView will be working with.
547: *
548: * @param itemSelector the items selector
549: */
550: public void setItemSelector(String itemSelector) {
551: setAttribute("itemSelector", itemSelector, true);
552: }
553:
554: /**
555: * A string to display during data load operations (defaults to undefined). If specified, this text will be displayed
556: * in a loading div and the view's contents will be cleared while loading, otherwise the view's contents will continue
557: * to display normally until the new data is loaded and the contents are replaced.
558: *
559: * @param loadingText the loading text
560: */
561: public void setLoadingText(String loadingText) {
562: setAttribute("loadingText", loadingText, true);
563: }
564:
565: /**
566: * True to allow selection of more than one item at a time, false to allow selection of only a single item at a time
567: * or no selection at all, depending on the value of singleSelect (defaults to false).
568: *
569: * @param multiSelect true to allow multiple selections
570: */
571: public void setMultiSelect(boolean multiSelect) {
572: setAttribute("multiSelect", multiSelect, true);
573: }
574:
575: /**
576: * A CSS class to apply to each item in the view on mouseover (defaults to undefined).
577: *
578: * @param overCls a CSS class to apply to each item in the view on mouseover (defaults to undefined).
579: * @throws IllegalStateException this property cannot be changed after the Component has been rendered
580: */
581: public void setOverCls(String overCls) throws IllegalStateException {
582: setAttribute("overClass", overCls, true);
583: }
584:
585: /**
586: * True to enable multiselection by clicking on multiple items without requiring the user to hold Shift or Ctrl,
587: * false to force the user to hold Ctrl or Shift to select more than on item (defaults to false).
588: *
589: * @param simpleSelect true to enable multiselection by clicking on multiple items without requiring the user to hold Shift or Ctrl
590: */
591: public void setSimpleSelect(boolean simpleSelect) {
592: setAttribute("simpleSelect", simpleSelect, true, true);
593: }
594:
595: /**
596: * True to allow selection of exactly one item at a time, false to allow no selection at all (defaults to false).
597: * Note that if multiSelect = true, this value will be ignored.
598: *
599: * @param singleSelect true to allow selection of exactly one item at a time, false to allow no selection at all
600: */
601: public void setSingleSelect(boolean singleSelect) {
602: setAttribute("singleSelect", singleSelect, true, true);
603: }
604:
605: /**
606: * The {@link Store} to bind this DataView to.
607: *
608: * @param store the Ext.data.Store to bind this DataView to.
609: */
610: public void setStore(Store store) {
611: if (!isRendered()) {
612: setAttribute("store", store.getJsObj(), true);
613: } else {
614: setStoreRendered(store.getJsObj());
615: }
616: }
617:
618: private native void setStoreRendered(JavaScriptObject storeJS) /*-{
619: var dv = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
620: dv.setStore(storeJS);
621: }-*/;
622:
623: /**
624: * An XTemplate constructed with the the HTML fragment or an array of fragments that will make up the template used
625: * by this DataView.
626: *
627: * @param tpl the DataView tempalte
628: */
629: public void setTpl(XTemplate tpl) {
630: setAttribute("tpl", tpl.getJsObj(), true, true);
631: }
632:
633: public static class Data extends GenericConfig {
634: public static Data instance(JavaScriptObject jsObj) {
635: return new Data(jsObj);
636: }
637:
638: private Data(JavaScriptObject jsObj) {
639: this.jsObj = jsObj;
640: }
641: }
642: }
|