| com.gwtext.client.widgets.Component com.gwtext.client.widgets.BoxComponent com.gwtext.client.widgets.DataView
DataView | public class DataView extends BoxComponent (Code) | | A mechanism for displaying data using custom layout templates and formatting. DataView uses
XTemplate as its internal
templating mechanisma, and is bound to an
Store so that as the data in the store changes the view is automatically
updated to reflect the changes. The view also provides built-in behavior for many common events that can occur for its contained
items including click, doubleclick, mouseover, mouseout, etc. as well as a built-in selection model.
An itemSelector which is passed to the constructor is used to determine what nodes it will be working with.
The example below binds a DataView to a Store and renders it into a
Panel .
// data here is Object[][] of local data.
MemoryProxy dataProxy = new MemoryProxy(getData());
ArrayReader reader = new ArrayReader(new RecordDef(new FieldDef[]{
new StringFieldDef("name"),
new IntegerFieldDef("size"),
new DateFieldDef("lastmod", "timestamp"),
new StringFieldDef("url")}));
Store store = new Store(dataProxy, reader);
store.load();
XTemplate template = new XTemplate(new String[]{
"<tpl for='.'>",
"<div class='thumb-wrap' id='{name}'>",
"<div class='thumb'><img src='{url}' title='{name}'></div>",
"<span class='x-editable'>{shortName}</span></div>",
"</tpl>",
"<div class='x-clear'></div>"});
Panel panel = new Panel();
panel.setId("images-view");
panel.setFrame(true);
panel.setAutoHeight(true);
panel.setCollapsible(true);
panel.setLayout(new FitLayout());
panel.setTitle("Simple DataView with editable labels, multi and drag selection");
//pre process the data from te store before passing it to the DataView
DataView dataView = new DataView("div.thumb-wrap") {
public void prepareData(Data data) {
data.setProperty("shortName", Format.ellipsis(data.getProperty("name"), 15));
} };
dataView.setStore(store);
dataView.setTpl(template);
dataView.setAutoHeight(true);
dataView.setMultiSelect(true);
dataView.setOverCls("x-view-over");
dataView.setEmptyText("No Images to display");
panel.add(dataView);
RootPanel.get().add(panel);
|
Constructor Summary | |
public | DataView(String itemSelector) Create a new DataView. | public | DataView(JavaScriptObject jsObj) |
Method Summary | |
native public void | addListener(DataViewListener listener) | native public void | clearSelections() Clears all selections. | native public void | clearSelections(boolean suppressEvent) Clears all selections. | native protected JavaScriptObject | create(JavaScriptObject config) | native public void | deselect(Element element) Deselects a node. | native public void | deselect(int nodeIndex) Deselects a node. | native public Element | findItemFromChild() Returns the template node the passed child belongs to, or null if it doesn't belong to one. | native public Element | getNode(String nodeID) Gets a template node. | native public Element | getNode(int nodeIndex) Gets a template node. | native public Element[] | getNodes(int start, int end) Gets a range nodes. | native public Record | getRecord(Element node) Gets a record from a node. | native public int[] | getSelectedIndexes() Gets the indexes of the selected nodes. | native public Record[] | getSelectedRecords() Gets an array of the selected records. | native public int | getSelectionCount() Gets the number of selected nodes. | public String | getXType() | native public int | indexOf(Element element) Finds the index of the passed node. | native public int | indexOf(String nodeID) Finds the index of the passed node. | native public int | indexOf(int nodeIndex) Finds the index of the passed node. | native public boolean | isSelected(Element element) Returns true if the passed node is selected, else false. | native public boolean | isSelected(int nodeIndex) Returns true if the passed node is selected, else false. | public void | prepareData(Data data) This method that can be overridden to provide custom formatting for the data that is sent to the template for each node. | native public void | refresh() Refreshes the view by reloading the data from the store and re-rendering the template. | native public void | refreshNode(int nodeIndex) Refreshes an individual node's data from the store. | native public void | select(Element node) Selectsthe node. | native public void | select(Element node, boolean keepExisting, boolean suppressEvent) Selects the node. | native public void | select(int nodeIndex) Selects the node. | native public void | select(int nodeIndex, boolean keepExisting, boolean suppressEvent) Selects the node. | native public void | select(int[] nodeIndexes) Selects a set of nodes. | native public void | select(int[] nodeIndexes, boolean keepExisting, boolean suppressEvent) Selects a set of nodes. | native public void | select(String[] nodeIDs) Selects a set of nodes. | native public void | select(String[] nodeIDs, boolean keepExisting, boolean suppressEvent) Selects a set of nodes. | native public void | selectRange(int start, int end) Selects a range of nodes. | native public void | selectRange(int start, int end, boolean keepExisting) Selects a range of nodes. | public void | setEmptyText(String emptyText) The text to display in the view when there is no data to display (defaults to ''). | public void | setItemSelector(String itemSelector) A CSS selector in any format supported by
com.gwtext.client.core.DomQuery that will be used to determine
what nodes this DataView will be working with. | public void | setLoadingText(String loadingText) A string to display during data load operations (defaults to undefined). | public void | setMultiSelect(boolean multiSelect) True to allow selection of more than one item at a time, false to allow selection of only a single item at a time
or no selection at all, depending on the value of singleSelect (defaults to false). | public void | setOverCls(String overCls) A CSS class to apply to each item in the view on mouseover (defaults to undefined). | public void | setSimpleSelect(boolean simpleSelect) True to enable multiselection by clicking on multiple items without requiring the user to hold Shift or Ctrl,
false to force the user to hold Ctrl or Shift to select more than on item (defaults to false). | public void | setSingleSelect(boolean singleSelect) True to allow selection of exactly one item at a time, false to allow no selection at all (defaults to false). | public void | setStore(Store store) The
Store to bind this DataView to. | public void | setTpl(XTemplate tpl) An XTemplate constructed with the the HTML fragment or an array of fragments that will make up the template used
by this DataView. |
DataView | public DataView(String itemSelector)(Code) | | Create a new DataView.
Parameters: itemSelector - a CSS selector in any format supported by com.gwtext.client.core.DomQuery that will be used to determinewhat nodes this DataView will be working with. |
DataView | public DataView(JavaScriptObject jsObj)(Code) | | |
clearSelections | native public void clearSelections()(Code) | | Clears all selections.
|
clearSelections | native public void clearSelections(boolean suppressEvent)(Code) | | Clears all selections.
Parameters: suppressEvent - true to prevent firing of the selectionchange event |
create | native protected JavaScriptObject create(JavaScriptObject config)(Code) | | |
deselect | native public void deselect(Element element)(Code) | | Deselects a node.
Parameters: element - the node to delselect |
deselect | native public void deselect(int nodeIndex)(Code) | | Deselects a node.
Parameters: nodeIndex - index of node to deselect |
findItemFromChild | native public Element findItemFromChild()(Code) | | Returns the template node the passed child belongs to, or null if it doesn't belong to one.
template node the child belongs to |
getNode | native public Element getNode(String nodeID)(Code) | | Gets a template node.
Parameters: nodeID - the id of a template node the node or null if it wasn't found |
getNode | native public Element getNode(int nodeIndex)(Code) | | Gets a template node.
Parameters: nodeIndex - the index of a template node the node or null if it wasn't found |
getNodes | native public Element[] getNodes(int start, int end)(Code) | | Gets a range nodes.
Parameters: start - the index of the first node in the range Parameters: end - the index of the last node in the range an array of nodes |
getRecord | native public Record getRecord(Element node)(Code) | | Gets a record from a node.
Parameters: node - The node to evaluate the Record |
getSelectedIndexes | native public int[] getSelectedIndexes()(Code) | | Gets the indexes of the selected nodes.
an array of numeric indexes |
getSelectedRecords | native public Record[] getSelectedRecords()(Code) | | Gets an array of the selected records.
an array of Records |
getSelectionCount | native public int getSelectionCount()(Code) | | Gets the number of selected nodes.
the node count |
indexOf | native public int indexOf(Element element)(Code) | | Finds the index of the passed node.
Parameters: element - the node The index of the node or -1 |
indexOf | native public int indexOf(String nodeID)(Code) | | Finds the index of the passed node.
Parameters: nodeID - the node ID The index of the node or -1 |
indexOf | native public int indexOf(int nodeIndex)(Code) | | Finds the index of the passed node.
Parameters: nodeIndex - the node index The index of the node or -1 |
isSelected | native public boolean isSelected(Element element)(Code) | | Returns true if the passed node is selected, else false.
Parameters: element - the node true if selected |
isSelected | native public boolean isSelected(int nodeIndex)(Code) | | Returns true if the passed node is selected, else false.
Parameters: nodeIndex - the node index true if selected |
prepareData | public void prepareData(Data data)(Code) | | This method that can be overridden to provide custom formatting for the data that is sent to the template for each node.
Data can be retried by name for lookup and new fields / value can be added to it/
Parameters: data - the view data |
refresh | native public void refresh()(Code) | | Refreshes the view by reloading the data from the store and re-rendering the template.
|
refreshNode | native public void refreshNode(int nodeIndex)(Code) | | Refreshes an individual node's data from the store.
Parameters: nodeIndex - the node index |
select | native public void select(Element node)(Code) | | Selectsthe node.
Parameters: node - the noed |
select | native public void select(Element node, boolean keepExisting, boolean suppressEvent)(Code) | | Selects the node.
Parameters: node - the node Parameters: keepExisting - true to keep existing selections Parameters: suppressEvent - true to skip firing of the selectionchange vent |
select | native public void select(int nodeIndex)(Code) | | Selects the node.
Parameters: nodeIndex - the node index |
select | native public void select(int nodeIndex, boolean keepExisting, boolean suppressEvent)(Code) | | Selects the node.
Parameters: nodeIndex - the node index Parameters: keepExisting - true to keep existing selections Parameters: suppressEvent - true to skip firing of the selectionchange event |
select | native public void select(int[] nodeIndexes)(Code) | | Selects a set of nodes.
Parameters: nodeIndexes - the node indexes |
select | native public void select(int[] nodeIndexes, boolean keepExisting, boolean suppressEvent)(Code) | | Selects a set of nodes.
Parameters: nodeIndexes - the node indexes Parameters: keepExisting - true to keep existing selections Parameters: suppressEvent - true to skip firing of the selectionchange event |
select | native public void select(String[] nodeIDs)(Code) | | Selects a set of nodes.
Parameters: nodeIDs - the node ID's |
select | native public void select(String[] nodeIDs, boolean keepExisting, boolean suppressEvent)(Code) | | Selects a set of nodes.
Parameters: nodeIDs - the node ID's Parameters: keepExisting - true to keep existing selections Parameters: suppressEvent - true to skip firing of the selectionchange event |
selectRange | native public void selectRange(int start, int end)(Code) | | Selects a range of nodes. All nodes between start and end are selected.
Parameters: start - The index of the first node in the range Parameters: end - The index of the last node in the range |
selectRange | native public void selectRange(int start, int end, boolean keepExisting)(Code) | | Selects a range of nodes. All nodes between start and end are selected.
Parameters: start - The index of the first node in the range Parameters: end - The index of the last node in the range Parameters: keepExisting - true to retain existing selections |
setEmptyText | public void setEmptyText(String emptyText)(Code) | | The text to display in the view when there is no data to display (defaults to '').
Parameters: emptyText - the empty text |
setItemSelector | public void setItemSelector(String itemSelector)(Code) | | A CSS selector in any format supported by
com.gwtext.client.core.DomQuery that will be used to determine
what nodes this DataView will be working with.
Parameters: itemSelector - the items selector |
setLoadingText | public void setLoadingText(String loadingText)(Code) | | A string to display during data load operations (defaults to undefined). If specified, this text will be displayed
in a loading div and the view's contents will be cleared while loading, otherwise the view's contents will continue
to display normally until the new data is loaded and the contents are replaced.
Parameters: loadingText - the loading text |
setMultiSelect | public void setMultiSelect(boolean multiSelect)(Code) | | True to allow selection of more than one item at a time, false to allow selection of only a single item at a time
or no selection at all, depending on the value of singleSelect (defaults to false).
Parameters: multiSelect - true to allow multiple selections |
setOverCls | public void setOverCls(String overCls) throws IllegalStateException(Code) | | A CSS class to apply to each item in the view on mouseover (defaults to undefined).
Parameters: overCls - a CSS class to apply to each item in the view on mouseover (defaults to undefined). throws: IllegalStateException - this property cannot be changed after the Component has been rendered |
setSimpleSelect | public void setSimpleSelect(boolean simpleSelect)(Code) | | True to enable multiselection by clicking on multiple items without requiring the user to hold Shift or Ctrl,
false to force the user to hold Ctrl or Shift to select more than on item (defaults to false).
Parameters: simpleSelect - true to enable multiselection by clicking on multiple items without requiring the user to hold Shift or Ctrl |
setSingleSelect | public void setSingleSelect(boolean singleSelect)(Code) | | True to allow selection of exactly one item at a time, false to allow no selection at all (defaults to false).
Note that if multiSelect = true, this value will be ignored.
Parameters: singleSelect - true to allow selection of exactly one item at a time, false to allow no selection at all |
setStore | public void setStore(Store store)(Code) | | The
Store to bind this DataView to.
Parameters: store - the Ext.data.Store to bind this DataView to. |
setTpl | public void setTpl(XTemplate tpl)(Code) | | An XTemplate constructed with the the HTML fragment or an array of fragments that will make up the template used
by this DataView.
Parameters: tpl - the DataView tempalte |
Methods inherited from com.gwtext.client.widgets.Component | public void addClass(String cls)(Code)(Java Doc) native public void addClassCreated(String cls)(Code)(Java Doc) native public void addEvent(String events)(Code)(Java Doc) public void addEvents(String[] events)(Code)(Java Doc) protected void addListener(String event, JavaScriptObject fn)(Code)(Java Doc) native public void addListener(String event, Function funtion)(Code)(Java Doc) native protected void addListener(ComponentListener listener)(Code)(Java Doc) protected void afterRender()(Code)(Java Doc) protected void beforeDestroy()(Code)(Java Doc) protected void check() throws IllegalStateException(Code)(Java Doc) public Component cloneComponent()(Code)(Java Doc) public Component cloneComponent(Component overrides)(Code)(Java Doc) native protected JavaScriptObject cloneConfig(JavaScriptObject config)(Code)(Java Doc) abstract protected JavaScriptObject create(JavaScriptObject config)(Code)(Java Doc) native public void destroy()(Code)(Java Doc) public void disable()(Code)(Java Doc) public void enable()(Code)(Java Doc) public boolean equals(Object obj)(Code)(Java Doc) protected void error(String message) throws IllegalStateException(Code)(Java Doc) public void focus()(Code)(Java Doc) native public void focus(boolean selectText)(Code)(Java Doc) native public void focus(boolean selectText, int delay)(Code)(Java Doc) public Element getApplyTo()(Code)(Java Doc) protected String getAttribute(String attribute)(Code)(Java Doc) protected boolean getAttributeAsBoolean(String attribute)(Code)(Java Doc) protected float getAttributeAsFloat(String attribute)(Code)(Java Doc) protected int getAttributeAsInt(String attribute)(Code)(Java Doc) protected JavaScriptObject getAttributeAsJavaScriptObject(String attribute)(Code)(Java Doc) public boolean getAutoShow()(Code)(Java Doc) public String getCls()(Code)(Java Doc) native protected static JavaScriptObject getComponentJS(String id)(Code)(Java Doc) public JavaScriptObject getConfig()(Code)(Java Doc) abstract protected JavaScriptObject getConfigPrototype()(Code)(Java Doc) public String getCtCls()(Code)(Java Doc) public String getDisabledClass()(Code)(Java Doc) native public ExtElement getEl()(Code)(Java Doc) native protected Element getElement(JavaScriptObject jsObj)(Code)(Java Doc) public Element getElement()(Code)(Java Doc) public String getHideMode()(Code)(Java Doc) public boolean getHideParent()(Code)(Java Doc) public String getId()(Code)(Java Doc) native public String getItemId()(Code)(Java Doc) public JavaScriptObject getJsObj()(Code)(Java Doc) public int getOffsetHeight()(Code)(Java Doc) public int getOffsetWidth()(Code)(Java Doc) public JavaScriptObject getOrCreateJsObj()(Code)(Java Doc) native public Container getOwnerContainer()(Code)(Java Doc) public Element getRenderTo()(Code)(Java Doc) public String[] getStateEvents()(Code)(Java Doc) public String getStateId()(Code)(Java Doc) public String getStyle()(Code)(Java Doc) protected Element getStyleElement()(Code)(Java Doc) public String getTitle()(Code)(Java Doc) public String getXType()(Code)(Java Doc) native public String getXTypes()(Code)(Java Doc) public int hashCode()(Code)(Java Doc) public void hide()(Code)(Java Doc) protected void initComponent()(Code)(Java Doc) public boolean isCreated()(Code)(Java Doc) public boolean isDisabled()(Code)(Java Doc) public boolean isHidden()(Code)(Java Doc) native public boolean isRendered()(Code)(Java Doc) native public boolean isVisible()(Code)(Java Doc) native public boolean isXType(String xtype)(Code)(Java Doc) native public boolean isXType(String xtype, boolean shallow)(Code)(Java Doc) protected void onDestroy()(Code)(Java Doc) native public void removeClass(String cls)(Code)(Java Doc) native public void render(String id)(Code)(Java Doc) native public void render(String id, String position)(Code)(Java Doc) native public void render(String id, int position)(Code)(Java Doc) native public void render(Element element)(Code)(Java Doc) native public void render(Element element, String position)(Code)(Java Doc) native public void render(Element element, int position)(Code)(Java Doc) public void setApplyTo(Element element) throws IllegalStateException(Code)(Java Doc) protected void setAttribute(String attribute, String value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, String value, boolean allowPostCreate, boolean allowPostRendered)(Code)(Java Doc) protected void setAttribute(String attribute, int[] value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, int[] value, boolean allowPostCreate, boolean allowPostRender)(Code)(Java Doc) protected void setAttribute(String attribute, long value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, double value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, int value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, int value, boolean allowPostCreate, boolean allowPostRender)(Code)(Java Doc) protected void setAttribute(String attribute, Date value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, JavaScriptObject value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, JavaScriptObject value, boolean allowPostCreate, boolean allowPostRender)(Code)(Java Doc) protected void setAttribute(String attribute, String[] value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, String[] value, boolean allowPostCreate, boolean allowPostRender)(Code)(Java Doc) protected void setAttribute(String attribute, boolean value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, boolean value, boolean allowPostCreate, boolean allowPostRendered)(Code)(Java Doc) protected void setAttribute(String attribute, Element value, boolean allowPostCreate)(Code)(Java Doc) protected void setAttribute(String attribute, Element value, boolean allowPostCreate, boolean allowPostRendered)(Code)(Java Doc) public void setAutoEl(String autoEl)(Code)(Java Doc) public void setAutoShow(boolean autoShow) throws IllegalStateException(Code)(Java Doc) public void setCls(String cls)(Code)(Java Doc) public void setCtCls(String ctCls) throws IllegalStateException(Code)(Java Doc) public void setDisabled(boolean disabled)(Code)(Java Doc) public void setDisabledClass(String disabledClass)(Code)(Java Doc) public void setEl(Element el) throws IllegalStateException(Code)(Java Doc) public void setEl(String elementID) throws IllegalStateException(Code)(Java Doc) public void setHeight(String height)(Code)(Java Doc) public void setHideMode(String hideMode)(Code)(Java Doc) public void setHideParent(boolean hideParent) throws IllegalStateException(Code)(Java Doc) final public void setId(String id) throws IllegalStateException(Code)(Java Doc) public void setRenderTo(Element elem) throws IllegalStateException(Code)(Java Doc) public void setStateEvents(String[] stateEvents) throws IllegalStateException(Code)(Java Doc) public void setStateId(String stateId) throws IllegalStateException(Code)(Java Doc) public void setStyle(String style) throws IllegalStateException(Code)(Java Doc) public void setTitle(String title)(Code)(Java Doc) public void setVisible(boolean visible)(Code)(Java Doc) public void setWidth(String width)(Code)(Java Doc) public void show()(Code)(Java Doc)
|
|
|