|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.sencha.gxt.widget.core.client.Component
com.sencha.gxt.widget.core.client.ListView<M,N>
M - the model typeN - the cell data typepublic class ListView<M,N>
A ListView provides support for displaying a list of data. The list
view gets its data from a ListStore. Each model in the store is
rendered as an item in the list view. Any updates to the store are
automatically pushed to the list view.
ModelKeyProviders and ValueProviders
provide the interface between your data model, the list store and the list
view. This enables a list view to work with data of any object type. The list
view uses a value provider, passed to the constructor, to get the value to
display for each model in the list view.
You can provide your own implementation of these interfaces, or you can use a
Sencha supplied generator to create them for you automatically. A generator
runs at compile time to create a Java class that is compiled to JavaScript.
The Sencha supplied generator can create classes for interfaces that extend
the PropertyAccess interface. The generator transparently creates the
class at compile time and the GWT.create(Class) method returns an
instance of that class at run time. The generated class is managed by GWT and
GXT and you generally do not need to worry about what the class is called,
where it is located, or other similar details.
To customize the appearance of the item in the list view, provide a cell
implementation using setCell(Cell).
The following code snippet illustrates the creation of a simple list view
with local data for test purposes. For more practical examples that show how
to customize list views to display images or use other types of cells, see
the ListView, Advanced ListView and DateCell ListView examples in the online
Explorer demo.
// Generate the key provider and value provider for the Data class
DataProperties dp = GWT.create(DataProperties.class);
// Create the store that the contains the data to display in the grid
ListStore<Data> s = new ListStore<Test.Data>(dp.key());
s.add(new Data("name1", "value1"));
s.add(new Data("name2", "value2"));
s.add(new Data("name3", "value3"));
s.add(new Data("name4", "value4"));
// Create the tree using the store and value provider for the name field
ListView<Data, String> t = new ListView<Data, String>(s, dp.name());
// Add the tree to a container
RootPanel.get().add(t);
To use the Sencha supplied generator to create model key providers and value
providers, extend the PropertyAccess interface, parameterized
with the type of data you want to access (as shown below) and invoke the
GWT.create method on its class member (as shown in
the code snippet above). This creates an instance of the class that can be
used to initialize the list view and list store. In the following code
snippet we define a new interface called DataProperties that
extends the PropertyAccess interface and is parameterized with
Data, a Plain Old Java Object (POJO).
public interface DataProperties extends PropertyAccess {
@Path("name")
ModelKeyProvider key();
ValueProvider<Data, String> name();
ValueProvider<Data, String> value();
}
public class Data {
private String name;
private String value;
public Data(String name, String value) {
super();
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
public void setName(String name) {
this.name = name;
}
public void setValue(String value) {
this.value = value;
}
}
| Nested Class Summary | |
|---|---|
static interface |
ListView.ListViewAppearance<M>
The appearance of a list view. |
static interface |
ListView.ListViewDefaultResources
The default resources for the list view. |
static interface |
ListView.ListViewDefaultStyle
The default styles for the list view. |
| Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
| Field Summary |
|---|
| Fields inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
DEBUG_ID_PREFIX |
| Constructor Summary | |
|---|---|
ListView(ListStore<M> store,
ValueProvider<? super M,N> valueProvider)
Creates a new list view. |
|
ListView(ListStore<M> store,
ValueProvider<? super M,N> valueProvider,
Cell<N> cell)
Creates a new list view. |
|
ListView(ListStore<M> store,
ValueProvider<? super M,N> valueProvider,
ListView.ListViewAppearance<M> appearance)
Creates a new list view. |
|
| Method Summary | |
|---|---|
HandlerRegistration |
addRefreshHandler(RefreshEvent.RefreshHandler handler)
Adds a RefreshEvent.RefreshHandler handler for
RefreshEvent events. |
Element |
findElement(Element element)
Returns the matching element. |
int |
findElementIndex(Element element)
Returns the element's index. |
void |
focus()
Try to focus this widget. |
Cell<N> |
getCell()
Returns the view's cell. |
XElement |
getElement(int index)
Returns the element at the given index. |
java.util.List<Element> |
getElements()
Returns all of the child elements. |
int |
getItemCount()
Returns the number of models in the view. |
java.lang.String |
getLoadingText()
Returns the view's loading text. |
QuickTip |
getQuickTip()
Returns the view's quick tip instance. |
ListViewSelectionModel<M> |
getSelectionModel()
Returns the view's selection model. |
boolean |
getSelectOnOver()
Returns true if select on hover is enabled. |
static ListView.ListViewDefaultResources |
getStandardResources()
Returns the default resources for the list view. |
ListStore<M> |
getStore()
Returns the combo's store. |
int |
indexOf(Element element)
Returns the index of the element. |
boolean |
isEnableQuickTips()
Returns true if quicktips are enabled. |
boolean |
isTrackMouseOver()
Returns true if items are highlighted on mouse over. |
void |
moveSelectedDown()
Moves the current selections down one level. |
void |
moveSelectedUp()
Moves the current selections up one level. |
void |
onBrowserEvent(Event event)
|
void |
refresh()
Refreshes the view by reloading the data from the store and re-rendering the template. |
void |
refreshNode(int index)
Refreshes an individual node's data from the store. |
void |
setAllowTextSelection(boolean enable)
Enables and disables text selection for the widget. |
void |
setCell(Cell<N> cell)
Optionally sets the view's cell. |
void |
setEnableQuickTips(boolean enableQuickTip)
True to enable quicktips (defaults to true, pre-render). |
void |
setLoadingText(java.lang.String loadingText)
Sets the text loading text to be displayed during a load request. |
void |
setSelectionModel(ListViewSelectionModel<M> sm)
Sets the selection model. |
void |
setSelectOnOver(boolean selectOnHover)
True to select the item when mousing over a element (defaults to false). |
void |
setStore(ListStore<M> store)
Changes the data store bound to this view and refreshes it. |
void |
setTrackMouseOver(boolean trackMouseOver)
True to highlight items when the mouse is over (defaults to true). |
| Methods inherited from class com.google.gwt.user.client.ui.Widget |
|---|
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents |
| Methods inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, removeStyleName, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toString, unsinkEvents |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ListView(ListStore<M> store,
ValueProvider<? super M,N> valueProvider)
store - the storevalueProvider - the value provider
public ListView(ListStore<M> store,
ValueProvider<? super M,N> valueProvider,
Cell<N> cell)
store - the storevalueProvider - the value providercell - the cell
public ListView(ListStore<M> store,
ValueProvider<? super M,N> valueProvider,
ListView.ListViewAppearance<M> appearance)
store - the storevalueProvider - the value providerappearance - the appearance| Method Detail |
|---|
public static ListView.ListViewDefaultResources getStandardResources()
public HandlerRegistration addRefreshHandler(RefreshEvent.RefreshHandler handler)
RefreshEvent.HasRefreshHandlersRefreshEvent.RefreshHandler handler for
RefreshEvent events.
addRefreshHandler in interface RefreshEvent.HasRefreshHandlershandler - the handler
public Element findElement(Element element)
element - the element or any child element
public int findElementIndex(Element element)
element - the element or any child element
public void focus()
Component
focus in class Componentpublic Cell<N> getCell()
public XElement getElement(int index)
index - the index
public java.util.List<Element> getElements()
public int getItemCount()
public java.lang.String getLoadingText()
public QuickTip getQuickTip()
public ListViewSelectionModel<M> getSelectionModel()
public boolean getSelectOnOver()
public ListStore<M> getStore()
public int indexOf(Element element)
element - the element
public boolean isEnableQuickTips()
public boolean isTrackMouseOver()
public void moveSelectedDown()
public void moveSelectedUp()
public void onBrowserEvent(Event event)
onBrowserEvent in interface EventListeneronBrowserEvent in class Componentpublic void refresh()
public void refreshNode(int index)
index - the items data index in the storepublic void setAllowTextSelection(boolean enable)
Component
setAllowTextSelection in class Componentenable - true to enable, false to disablepublic void setCell(Cell<N> cell)
cell - the cellpublic void setEnableQuickTips(boolean enableQuickTip)
enableQuickTip - true to enable quicktipspublic void setLoadingText(java.lang.String loadingText)
loadingText - the loading textpublic void setSelectionModel(ListViewSelectionModel<M> sm)
sm - the selection modelpublic void setSelectOnOver(boolean selectOnHover)
selectOnHover - true to select on mouse overpublic void setStore(ListStore<M> store)
store - the store to bind this viewpublic void setTrackMouseOver(boolean trackMouseOver)
trackMouseOver - true to highlight rows on mouse over
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||