Package com.inmethod.grid.datagrid
Class DataGrid<D extends IDataSource<T>,T,S>
- java.lang.Object
-
- org.apache.wicket.Component
-
- org.apache.wicket.MarkupContainer
-
- org.apache.wicket.markup.html.WebMarkupContainer
-
- org.apache.wicket.markup.html.panel.Panel
-
- com.inmethod.grid.common.AbstractGrid<D,T,S>
-
- com.inmethod.grid.datagrid.DataGrid<D,T,S>
-
- Type Parameters:
D- datasource model object type = grid typeT- row/item model object type
- All Implemented Interfaces:
Serializable,Iterable<Component>,IEventSink,IEventSource,IFeedbackContributor,IConverterLocator,IMetadataContext<Serializable,Component>,IQueueRegion,IHeaderContributor,IPageable,IRequestableComponent,IHierarchical<Component>,IClusterable
- Direct Known Subclasses:
DefaultDataGrid
public class DataGrid<D extends IDataSource<T>,T,S> extends AbstractGrid<D,T,S> implements IPageable
Advanced grid component. Supports resizable and reorderable columns.- Author:
- Matej Knopp
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDataGrid.IGridQueryExtended query interface that makes it possible to obtain theDataGridinstance.
-
Field Summary
-
Fields inherited from class com.inmethod.grid.common.AbstractGrid
CSS, INTERNAL_TOOLBAR_ITEM_ID, JS_DOM, JS_EVENT, JS_SCRIPT, JS_SCRIPT_JQ, JS_YAHOO, THEME_VISTA
-
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebMarkupContainerfindParentRow(Component child)Returns the row in DataTable that contains the child componentprotected WebMarkupContainerfindRowComponent(IModel<T> rowModel)Returns the row component for specified item.longgetCurrentPage()longgetCurrentPageItemCount()DgetDataSource()Returns theIDataSourceinstance this data grid uses to fetch the data.longgetPageCount()Gets the total number of pages this pageable object has.longgetRowsPerPage()Returns the maximal amount of rows shown on one page.Collection<IModel<T>>getSelectedItems()Returns the collection of models of all currently selected items.longgetTotalRowCount()Returns the total count of items (sum of count of items on all pages) orAbstractPageableView.UNKNOWN_COUNTin case the count can't be determined.Item<T>insertRow(T rowData)Insert the rowData into the gridbooleanisAllowSelectMultiple()Returns whether user will be able to select more than one item at a time.booleanisCleanSelectionOnPageChange()booleanisItemSelected(IModel<T> itemModel)Queries whether the item specified by itemModel is currently selected.voidmarkAllItemsDirty()Makes the next call toupdate()refresh the entire grid.voidmarkItemDirty(IModel<T> itemModel)Marks the item from the given model as dirty.protected voidonBeforeRender()voidonItemSelectionChanged(IModel<T> item, boolean newValue)Invoked when an item selection state has been changed.voidresetSelectedItems()Deselects all items.voidselectAllVisibleItems()Marks all currently displayed items as selected.voidselectItem(IModel<T> itemModel, boolean selected)Alters the selection state of item specified by the item model.voidsetAllowSelectMultiple(boolean value)Sets whether user will be able to select more than one item.DataGrid<D,T,S>setCleanSelectionOnPageChange(boolean cleanSelectionOnPageChange)Sets whether the change of current page should clear all selected items.voidsetCurrentPage(long page)Sets the a page that should be rendered.DataGrid<D,T,S>setRowsPerPage(int rowsPerPage)Sets the desired amount rows per page.voidupdate()During an Ajax request this method updates the changed grid rows.-
Methods inherited from class com.inmethod.grid.common.AbstractGrid
addBottomToolbar, addHeaderToolbar, addTopToolbar, cleanLastClickedColumn, columnSanityCheck, disableRowClickNotifications, getActiveColumns, getAllColumns, getColumnState, getContentHeight, getContentHeightSizeUnit, getForm, getLastClickedColumn, getSortState, getTheme, isClickRowToDeselect, isClickRowToSelect, isItemEdited, isSelectToEdit, isUseYui, onAfterRender, onCellClicked, onColumnStateChanged, onComponentTag, onInitialize, onRowClicked, onRowPopulated, onSortStateChanged, renderHead, setClickRowToDeselect, setClickRowToSelect, setColumnState, setContentHeight, setItemEdit, setSelectToEdit, setTheme, setUseYui
-
Methods inherited from class org.apache.wicket.markup.html.panel.Panel
getRegionMarkup, newMarkupSourcingStrategy
-
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
-
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onDetach, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
-
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.IQueueRegion
dequeue, newDequeueContext
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
DataGrid
public DataGrid(String id, IModel<D> model, List<IGridColumn<D,T,S>> columns)
Crates a newDataGridinstance.- Parameters:
id- component idmodel- model to access theIDataSourceinstance used to fetch the datacolumns- list of grid columns
-
-
Method Detail
-
getDataSource
public D getDataSource()
Returns theIDataSourceinstance this data grid uses to fetch the data.- Returns:
IDataSourceinstance
-
setRowsPerPage
public DataGrid<D,T,S> setRowsPerPage(int rowsPerPage)
Sets the desired amount rows per page.- Parameters:
rowsPerPage- how many rows (max) should be displayed on one page- Returns:
this(useful for method chaining)
-
getRowsPerPage
public long getRowsPerPage()
Returns the maximal amount of rows shown on one page.- Returns:
- count of rows per page
-
getTotalRowCount
public long getTotalRowCount()
Returns the total count of items (sum of count of items on all pages) orAbstractPageableView.UNKNOWN_COUNTin case the count can't be determined.- Returns:
- total count of items or -1L
-
getCurrentPage
public long getCurrentPage()
- Specified by:
getCurrentPagein interfaceIPageable- Returns:
- The current page that is or will be rendered.
-
getPageCount
public long getPageCount()
Gets the total number of pages this pageable object has.- Specified by:
getPageCountin interfaceIPageable- Returns:
- The total number of pages this pageable object has
-
setCurrentPage
public void setCurrentPage(long page)
Sets the a page that should be rendered.- Specified by:
setCurrentPagein interfaceIPageable- Parameters:
page- The page that should be rendered.
-
getCurrentPageItemCount
public long getCurrentPageItemCount()
- Returns:
- the amount of items on current page.
-
getSelectedItems
public Collection<IModel<T>> getSelectedItems()
Returns the collection of models of all currently selected items.- Specified by:
getSelectedItemsin classAbstractGrid<D extends IDataSource<T>,T,S>- Returns:
- collection of models of currently selected items
-
isAllowSelectMultiple
public boolean isAllowSelectMultiple()
Returns whether user will be able to select more than one item at a time.- Specified by:
isAllowSelectMultiplein classAbstractGrid<D extends IDataSource<T>,T,S>- Returns:
trueif multiple items can be selected at a time,falseotherwise.
-
setAllowSelectMultiple
public void setAllowSelectMultiple(boolean value)
Sets whether user will be able to select more than one item.- Specified by:
setAllowSelectMultiplein classAbstractGrid<D extends IDataSource<T>,T,S>- Parameters:
value-trueif the user will be able to select more than one item at a time,falseotherwise (single selection mode).
-
setCleanSelectionOnPageChange
public DataGrid<D,T,S> setCleanSelectionOnPageChange(boolean cleanSelectionOnPageChange)
Sets whether the change of current page should clear all selected items. This means that only items on current page can be selected, i.e. items from multiple pages can not be selected at the same time.- Parameters:
cleanSelectionOnPageChange- whether the current page change should deselect all selected items- Returns:
this(useful for method chaining)
-
isCleanSelectionOnPageChange
public boolean isCleanSelectionOnPageChange()
- Returns:
- whether the current page change cleans the selection
-
isItemSelected
public boolean isItemSelected(IModel<T> itemModel)
Queries whether the item specified by itemModel is currently selected.- Specified by:
isItemSelectedin classAbstractGrid<D extends IDataSource<T>,T,S>- Parameters:
itemModel- item model- Returns:
trueif the item is selected,falseotherwise
-
resetSelectedItems
public void resetSelectedItems()
Deselects all items. This method marks all items (not just visible items) as no selected.- Specified by:
resetSelectedItemsin classAbstractGrid<D extends IDataSource<T>,T,S>
-
selectAllVisibleItems
public void selectAllVisibleItems()
Marks all currently displayed items as selected. ForDataGridthis selects all items on current page, forTreeGridthis selects all currently visible nodes.- Specified by:
selectAllVisibleItemsin classAbstractGrid<D extends IDataSource<T>,T,S>
-
findRowComponent
protected WebMarkupContainer findRowComponent(IModel<T> rowModel)
Returns the row component for specified item.- Specified by:
findRowComponentin classAbstractGrid<D extends IDataSource<T>,T,S>- Returns:
-
onBeforeRender
protected void onBeforeRender()
- Overrides:
onBeforeRenderin classAbstractGrid<D extends IDataSource<T>,T,S>
-
markItemDirty
public void markItemDirty(IModel<T> itemModel)
Marks the item from the given model as dirty. Dirty items are updated during Ajax requests whenAbstractGrid.update()method is called.- Specified by:
markItemDirtyin classAbstractGrid<D extends IDataSource<T>,T,S>- Parameters:
itemModel- model used to access the item
-
markAllItemsDirty
public void markAllItemsDirty()
Makes the next call toupdate()refresh the entire grid.
-
onItemSelectionChanged
public void onItemSelectionChanged(IModel<T> item, boolean newValue)
Invoked when an item selection state has been changed.- Overrides:
onItemSelectionChangedin classAbstractGrid<D extends IDataSource<T>,T,S>- Parameters:
item- item modelnewValue-trueif the item became selected,falseotherwise.
-
update
public void update()
During an Ajax request this method updates the changed grid rows.The definition of "changed" varies in
DataGridandTreeGrid.- In both grids the items for which the selection state changed are considered changed.
- In
TreeGridthe changes toTreeModelitself are being tracked (assuming the proper listeners are fired) and all rows that need to be updated are also considered changed. - In
DataGridthe items that need to be updated can be marked bymarkItemDirty(IModel)ormarkAllItemsDirty(). The grid itself doesn't track changes to specific items (apart from the selection state).
- Specified by:
updatein classAbstractGrid<D extends IDataSource<T>,T,S>
-
insertRow
public Item<T> insertRow(T rowData)
Insert the rowData into the grid- Parameters:
rowData- data to insert into the new row- Returns:
- Item inserted Item
-
selectItem
public void selectItem(IModel<T> itemModel, boolean selected)
Alters the selection state of item specified by the item model.- Specified by:
selectItemin classAbstractGrid<D extends IDataSource<T>,T,S>- Parameters:
itemModel- item modelselected-trueif the item should be selected,falseotherwise.
-
findParentRow
public WebMarkupContainer findParentRow(Component child)
Returns the row in DataTable that contains the child component- Specified by:
findParentRowin classAbstractGrid<D extends IDataSource<T>,T,S>- Returns:
-
-