com.extjs.gxt.ui.client.widget
Class DataView

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Container<T>
                      extended by com.extjs.gxt.ui.client.widget.ScrollContainer<DataViewItem>
                          extended by com.extjs.gxt.ui.client.widget.DataView
All Implemented Interfaces:
Observable, Selectable<DataViewItem>, com.google.gwt.user.client.EventListener

public class DataView
extends ScrollContainer<DataViewItem>
implements Selectable<DataViewItem>

A mechanism for displaying data using custom layout templates. DataView uses an Template as its internal templating mechanism.

A itemSelector MUST be provided for the DataView to determine what nodes it will be working with.

Events:
BeforeAdd : DataViewEvent(view, item, index)
Fires before an item is added or inserted. Listeners can set the doit field to false to cancel the action.
BeforeRemove : DataViewEvent(view, item)
Fires before an item is removed. Listeners can set the doit field to false to cancel the action.
Add : DataViewEvent(view, item, index)
Fires after an item has been added or inserted.
Remove : DataViewEvent(view, item)
Fires after an item has been removed.
SelectionChange : DataViewEvent(view, selected)
Fires after the selection changes.
ContextMenu : DataViewEvent(view)
Fires before the view's context menu is shown. Listeners can set the doit field to false to cancel the action.


Nested Class Summary
 class DataView.DataViewSelectionModel
          Data view selection model.
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
DataView()
          Creates a new data view.
DataView(Template template)
          Creates a new data view with the given template.
 
Method Summary
 boolean add(DataViewItem component)
          Adds a item to the container.
 DataViewBinder getBinder()
          Returns the view's binder.
 java.lang.String getContainerTagName()
          Returns the container's tag name.
 Menu getContextMenu()
          Returns the component's context menu.
 java.lang.String getDefaultTemplate()
          Returns the default template.
 java.lang.String getItemSelector()
          Returns the item selector.
 java.lang.String getOverStyle()
          Returns the over style.
 DataViewItem getSelectedItem()
          Returns the selected item.
 java.util.List<DataViewItem> getSelectedItems()
          Returns the selected items.
 Style.SelectionMode getSelectionMode()
          Returns the view's selection mode.
 DataView.DataViewSelectionModel getSelectionModel()
          Returns the view's selection model.
 boolean getSelectOnOver()
          Returns true if select on hover is enabled.
 java.lang.String getSelectStyle()
          Returns the select style.
 Template getTemplate()
          Returns the view's template.
 boolean insert(DataViewItem item, int index)
          Adds a item into the container.
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
 void onSelectChange(DataViewItem item, boolean select)
          Called when the visual state of a item is changed.
 boolean remove(DataViewItem component)
          Removes the item from the container.
 void setContainerTagName(java.lang.String containerTagName)
          Sets the container's tag name (defaults to 'div', pre-render).
 void setContextMenu(Menu menu)
          Sets the component's context menu.
 void setDefaultTemplate(java.lang.String defaultTemplate)
          Sets the default template.
 void setItemSelector(java.lang.String itemSelector)
          This is a required setting.
 void setOverStyle(java.lang.String overStyle)
          Sets the style name to be applied on mouse over (defaults to 'x-view-item-over').
 void setSelectedItem(DataViewItem item)
          Selects the item.
 void setSelectedItems(java.util.List<DataViewItem> items)
          Selects the items.
 void setSelectionMode(Style.SelectionMode mode)
          Sets the list's selection mode.
 void setSelectOnOver(boolean selectOnHover)
          True to select the item when mousing over a element (defaults to false).
 void setSelectStyle(java.lang.String selectStyle)
          The style to be applied to each selected item (defaults to 'x-view-item-sel').
 void setStore(ListStore store)
          Convenience method that create a new DataViewBinder using the given store.
 void setTemplate(java.lang.String html)
          Sets the view's template.
 void setTemplate(Template template)
          Sets the view's template.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.ScrollContainer
addScrollListener, getHScrollPosition, getScrollMode, getVScrollPosition, removeScrollListener, scrollIntoView, setHScrollPosition, setScrollMode, setVScrollPosition
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Container
disable, enable, findItem, getItem, getItemByItemId, getItemCount, getItems, getWidget, indexOf, iterator, removeAll, scrollIntoView
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
getBounds, getHeight, getHeight, getPosition, getShadow, getSize, getWidth, getWidth, isAutoHeight, isAutoWidth, isDeferHeight, isShim, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShim, setSize, setSize, setWidth, setWidth
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addPlugin, addStyleName, addWidgetListener, disableEvents, disableTextSelection, el, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getData, getData, getElement, getId, getItemId, getModel, getState, getToolTip, hide, hideToolTip, isDisabledEvents, isEnabled, isRendered, isVisible, onBrowserEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeWidgetListener, render, render, saveState, setBorders, setData, setData, setElement, setEnabled, setEnableState, setId, setIntStyleAttribute, setItemId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, show, sinkEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataView

public DataView()
Creates a new data view.


DataView

public DataView(Template template)
Creates a new data view with the given template.

Parameters:
template - the template
Method Detail

add

public boolean add(DataViewItem component)
Description copied from class: Container
Adds a item to the container. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
component - the item to be added

getBinder

public DataViewBinder getBinder()
Returns the view's binder. Only applies when set setStore(ListStore) is used.

Returns:
the binder

getContainerTagName

public java.lang.String getContainerTagName()
Returns the container's tag name.

Returns:
the container tag anme

getContextMenu

public Menu getContextMenu()
Description copied from class: Component
Returns the component's context menu. This method is marked protected, subclasses can change access to public to expose the contenxt menu.

Returns:
the context menu

getDefaultTemplate

public java.lang.String getDefaultTemplate()
Returns the default template.

Returns:
the default template

getItemSelector

public java.lang.String getItemSelector()
Returns the item selector.

Returns:
the selector

getOverStyle

public java.lang.String getOverStyle()
Returns the over style.

Returns:
the over style

getSelectedItem

public DataViewItem getSelectedItem()
Description copied from interface: Selectable
Returns the selected item.

Specified by:
getSelectedItem in interface Selectable<DataViewItem>
Returns:
the selected item

getSelectedItems

public java.util.List<DataViewItem> getSelectedItems()
Description copied from interface: Selectable
Returns the selected items. For single-select, the last selected item is returned.

Specified by:
getSelectedItems in interface Selectable<DataViewItem>
Returns:
the selected items

getSelectionMode

public Style.SelectionMode getSelectionMode()
Returns the view's selection mode.

Returns:
the selection mode.

getSelectionModel

public DataView.DataViewSelectionModel getSelectionModel()
Returns the view's selection model.

Returns:
the selection model

getSelectOnOver

public boolean getSelectOnOver()
Returns true if select on hover is enabled.

Returns:
the select on hover state

getSelectStyle

public java.lang.String getSelectStyle()
Returns the select style.

Returns:
the select style

getTemplate

public Template getTemplate()
Returns the view's template.

Returns:
the template

insert

public boolean insert(DataViewItem item,
                      int index)
Description copied from class: Container
Adds a item into the container. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
item - the item to insert
index - the insert location

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class ScrollContainer<DataViewItem>
Parameters:
ce - the base event

onSelectChange

public void onSelectChange(DataViewItem item,
                           boolean select)
Description copied from interface: Selectable
Called when the visual state of a item is changed.

Specified by:
onSelectChange in interface Selectable<DataViewItem>
Parameters:
item - the item
select - the select state

remove

public boolean remove(DataViewItem component)
Description copied from class: Container
Removes the item from the container. Fires the BeforeRemove event before removing, then fires the Remove event after the widget has been removed.

Parameters:
component - the item to remove
Returns:
true if the item was removed

setContainerTagName

public void setContainerTagName(java.lang.String containerTagName)
Sets the container's tag name (defaults to 'div', pre-render).

Parameters:
containerTagName -

setContextMenu

public void setContextMenu(Menu menu)
Description copied from class: Component
Sets the component's context menu.

Parameters:
menu - the context menu

setDefaultTemplate

public void setDefaultTemplate(java.lang.String defaultTemplate)
Sets the default template.

Parameters:
defaultTemplate - the default template

setItemSelector

public void setItemSelector(java.lang.String itemSelector)
This is a required setting. A simple CSS selector (e.g. div.some-class or span:first-child) that will be used to determine what nodes this DataView will be working with (defaults to 'x-view-item').

Parameters:
itemSelector - the item selector

setOverStyle

public void setOverStyle(java.lang.String overStyle)
Sets the style name to be applied on mouse over (defaults to 'x-view-item-over').

Parameters:
overStyle - the over style

setSelectedItem

public void setSelectedItem(DataViewItem item)
Description copied from interface: Selectable
Selects the item. Any existing selections are cleared.

Specified by:
setSelectedItem in interface Selectable<DataViewItem>
Parameters:
item - the item to select

setSelectedItems

public void setSelectedItems(java.util.List<DataViewItem> items)
Description copied from interface: Selectable
Selects the items. Only the first item is selected for single-select. Any existing selections are cleared.

Specified by:
setSelectedItems in interface Selectable<DataViewItem>
Parameters:
items - the items to select

setSelectionMode

public void setSelectionMode(Style.SelectionMode mode)
Sets the list's selection mode.

Parameters:
mode - the selection mode

setSelectOnOver

public void setSelectOnOver(boolean selectOnHover)
True to select the item when mousing over a element (defaults to false).

Parameters:
selectOnHover - true to select on mouse over

setSelectStyle

public void setSelectStyle(java.lang.String selectStyle)
The style to be applied to each selected item (defaults to 'x-view-item-sel').

Parameters:
selectStyle - the select style

setStore

public void setStore(ListStore store)
Convenience method that create a new DataViewBinder using the given store.

Parameters:
store - the store

setTemplate

public void setTemplate(java.lang.String html)
Sets the view's template.

Parameters:
html - the HTML fragment

setTemplate

public void setTemplate(Template template)
Sets the view's template.

Parameters:
template - the template