Class TDataGrid
TDataGrid class
TDataGrid represents a data bound and updatable grid control. To populate data into the datagrid, sets its DataSource to a tabular data source and call dataBind(). Each row of data will be represented by an item in the Items collection of the datagrid. An item can be at one of three states: browsing, selected and edit. The state determines how the item will be displayed. For example, if an item is in edit state, it may be displayed as a table row with input text boxes if the columns are of type TBoundColumn; and if in browsing state, they are displayed as static text. To change the state of an item, set EditItemIndex or SelectedItemIndex property. Each datagrid item has a TDataGridItem::getItemType which tells the position and state of the item in the datalist. An item in the header of the repeater is of type Header. A body item may be of either Item, AlternatingItem, SelectedItem or EditItem, depending whether the item index is odd or even, whether it is being selected or edited. A datagrid is specified with a list of columns. Each column specifies how the corresponding table column will be displayed. For example, the header/footer text of that column, the cells in that column, and so on. The following column types are currently provided by the framework, - TBoundColumn, associated with a specific field in datasource and displays the corresponding data.
- TEditCommandColumn, displaying edit/update/cancel command buttons
- TButtonColumn, displaying generic command buttons that may be bound to specific field in datasource.
- TDropDownListColumn, displaying a dropdown list when the item is in edit state
- THyperLinkColumn, displaying a hyperlink that may be bound to specific field in datasource.
- TCheckBoxColumn, displaying a checkbox that may be bound to specific field in datasource.
- TTemplateColumn, displaying content based on templates.
There are three ways to specify columns for a datagrid. - Automatically generated based on data source.
By setting AutoGenerateColumns to true,
a list of columns will be automatically generated based on the schema of the data source.
Each column corresponds to a column of the data.
- Specified in template. For example,
- Manually created in code. Columns can be manipulated via
the setColumns property of the datagrid. For example,
Note, automatically generated columns cannot be accessed via the Columns property. TDataGrid supports sorting. If the AllowSorting is set to true, a column with nonempty setSortExpression will have its header text displayed as a clickable link button. Clicking on the link button will raise OnSortCommand event. You can respond to this event, sort the data source according to the event parameter, and then invoke databind() on the datagrid to show to end users the sorted data. TDataGrid supports paging. If the AllowPaging is set to true, a pager will be displayed on top and/or bottom of the table. How the pager will be displayed is determined by the PagerStyle property. Clicking on a pager button will raise an OnPageIndexChanged event. You can respond to this event, specify the page to be displayed by setting CurrentPageIndex</b> property, and then invoke databind() on the datagrid to show to end users a new page of data. TDataGrid supports two kinds of paging. The first one is based on the number of data items in datasource. The number of pages PageCount is calculated based the item number and the PageSize property. The datagrid will manage which section of the data source to be displayed based on the CurrentPageIndex property. The second approach calculates the page number based on the VirtualItemCount property and the PageSize property. The datagrid will always display from the beginning of the datasource up to the number of PageSize data items. This approach is especially useful when the datasource may contain too many data items to be managed by the datagrid efficiently. When the datagrid contains a button control that raises an onCommand event, the event will be bubbled up to the datagrid control. If the event's command name is recognizable by the datagrid control, a corresponding item event will be raised. The following item events will be raised upon a specific command: - OnEditCommand, if CommandName=edit
- OnCancelCommand, if CommandName=cancel
- OnSelectCommand, if CommandName=select
- OnDeleteCommand, if CommandName=delete
- OnUpdateCommand, if CommandName=update
- onPageIndexChanged, if CommandName=page
- OnSortCommand, if CommandName=sort
Note, an OnItemCommand event is raised in addition to the above specific command events. TDataGrid also raises an OnItemCreated event for every newly created datagrid item. You can respond to this event to customize the content or style of the newly created item. Note, the data bound to the datagrid are reset to null after databinding. There are several ways to access the data associated with a datagrid row: the specified datagrid row and use the key to fetch the corresponding data from some persistent storage such as DB. - Save the data in viewstate and get it back during postbacks.
| Constants Inherited From TControl |
|
AUTOMATIC_ID_PREFIX,
CLIENT_ID_SEPARATOR,
CS_CHILD_INITIALIZED,
CS_CONSTRUCTED,
CS_INITIALIZED,
CS_LOADED,
CS_PRERENDERED,
CS_STATE_LOADED,
ID_FORMAT,
ID_SEPARATOR,
IS_CHILD_CREATED,
IS_CREATING_CHILD,
IS_DISABLE_THEMING,
IS_DISABLE_VIEWSTATE,
IS_ID_SET,
IS_SKIN_APPLIED,
IS_STYLESHEET_APPLIED,
RF_ADAPTER,
RF_AUTO_BINDINGS,
RF_CHILD_STATE,
RF_CONTROLS,
RF_CONTROLSTATE,
RF_DATA_BINDINGS,
RF_EVENTS,
RF_NAMED_CONTROLS,
RF_NAMED_CONTROLS_ID,
RF_NAMED_OBJECTS,
RF_SKIN_ID,
|
| Method Summary |
|
void
|
Adds objects parsed in template to datagrid.
|
|
protected
void
|
Applies styles to items, header, footer and separators.
|
|
boolean
|
This method overrides parent's implementation to handle onItemCommand event which is bubbled from TDataGridItem child controls.
|
|
protected
void
|
Builds a next-prev pager
|
|
protected
void
|
Builds a numeric pager
|
|
protected
void
|
Builds the pager content based on pager style.
|
|
protected
TDataGridColumnCollection
|
Automatically generates datagrid columns based on datasource schema
|
|
protected
TDataGridItem
|
Creates a datagrid item instance based on the item type and index.
|
|
protected
mixed
|
createPagerButton
( string $buttonType, boolean $enabled, string $text, string $commandName, string $commandParameter)
Creates a pager button.
|
|
protected
TTableStyle
|
Creates a style object for the control.
|
|
boolean
|
|
|
TTableItemStyle
|
|
|
TDataGridColumnCollection
|
|
|
boolean
|
|
|
string
|
|
|
TDataGridPager
|
|
|
string
|
|
|
TTableCaptionAlign
|
|
|
TDataGridColumnCollection
|
|
|
TDataGridItem
|
|
|
integer
|
|
|
TTableItemStyle
|
|
|
ITemplate
|
|
|
TDataGridItem
|
|
|
TTableItemStyle
|
|
|
TDataGridItem
|
|
|
TTableItemStyle
|
|
|
integer
|
|
|
TDataGridItemCollection
|
|
|
TTableItemStyle
|
|
|
TDataGridPagerStyle
|
|
|
TDataGridItem
|
|
|
integer
|
|
|
TTableItemStyle
|
|
|
boolean
|
|
|
boolean
|
|
|
TStyle
|
|
|
TStyle
|
|
|
TStyle
|
|
|
protected
string
|
|
|
TDataGridPager
|
|
|
protected
void
|
Initializes a datagrid item and cells inside it
|
|
void
|
Loads item count information from viewstate.
|
|
void
|
Raises OnCancelCommand event.
|
|
void
|
Raises OnDeleteCommand event.
|
|
void
|
Raises OnEditCommand event.
|
|
void
|
Raises OnItemCommand event.
|
|
void
|
Raises OnItemCreated event.
|
|
void
|
Raises OnItemDataBound event.
|
|
void
|
Raises OnPageIndexChanged event.
|
|
void
|
Raises OnPagerCreated event.
|
|
void
|
Raises OnSortCommand event.
|
|
void
|
Raises OnUpdateCommand event.
|
|
protected
void
|
Performs databinding to populate datagrid items from data source.
|
|
void
|
Renders the datagrid.
|
|
void
|
Renders the openning tag for the datagrid control which will render table caption if present.
|
|
protected
void
|
Renders the tabular data.
|
|
void
|
Clears up all items in the datagrid.
|
|
protected
void
|
Restores datagrid content from viewstate.
|
|
void
|
Saves item count in viewstate.
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
Edits an item by its index in getItems.
|
|
void
|
|
|
void
|
Selects an item by its index in getItems.
|
|
void
|
|
|
void
|
|
| Methods Inherited From TBaseDataList |
|
TBaseDataList::createStyle(), TBaseDataList::getCellPadding(), TBaseDataList::getCellSpacing(), TBaseDataList::getDataFieldValue(), TBaseDataList::getDataKeyField(), TBaseDataList::getDataKeys(), TBaseDataList::getGridLines(), TBaseDataList::getHorizontalAlign(), TBaseDataList::onSelectedIndexChanged(), TBaseDataList::setCellPadding(), TBaseDataList::setCellSpacing(), TBaseDataList::setDataKeyField(), TBaseDataList::setGridLines(), TBaseDataList::setHorizontalAlign()
|
| Methods Inherited From TDataBoundControl |
|
TDataBoundControl::createPagedDataSource(), TDataBoundControl::dataBind(), TDataBoundControl::dataSourceViewChanged(), TDataBoundControl::determineDataSource(), TDataBoundControl::ensureDataBound(), TDataBoundControl::getAllowCustomPaging(), TDataBoundControl::getAllowPaging(), TDataBoundControl::getCurrentPageIndex(), TDataBoundControl::getDataMember(), TDataBoundControl::getDataSource(), TDataBoundControl::getDataSourceID(), TDataBoundControl::getDataSourceView(), TDataBoundControl::getInitialized(), TDataBoundControl::getIsDataBound(), TDataBoundControl::getPageCount(), TDataBoundControl::getPageSize(), TDataBoundControl::getRequiresDataBinding(), TDataBoundControl::getSelectParameters(), TDataBoundControl::getUsingDataSourceID(), TDataBoundControl::getVirtualItemCount(), TDataBoundControl::onDataBound(), TDataBoundControl::onDataSourceChanged(), TDataBoundControl::onInit(), TDataBoundControl::onPreRender(), TDataBoundControl::pagePreLoad(), TDataBoundControl::setAllowCustomPaging(), TDataBoundControl::setAllowPaging(), TDataBoundControl::setCurrentPageIndex(), TDataBoundControl::setDataMember(), TDataBoundControl::setDataSource(), TDataBoundControl::setDataSourceID(), TDataBoundControl::setInitialized(), TDataBoundControl::setIsDataBound(), TDataBoundControl::setPageSize(), TDataBoundControl::setRequiresDataBinding(), TDataBoundControl::setVirtualItemCount(), TDataBoundControl::validateDataSource()
|
| Methods Inherited From TWebControl |
|
TWebControl::addAttributesToRender(), TWebControl::clearStyle(), TWebControl::copyBaseAttributes(), TWebControl::createStyle(), TWebControl::getAccessKey(), TWebControl::getBackColor(), TWebControl::getBorderColor(), TWebControl::getBorderStyle(), TWebControl::getBorderWidth(), TWebControl::getCssClass(), TWebControl::getDisplay(), TWebControl::getFont(), TWebControl::getForeColor(), TWebControl::getHasStyle(), TWebControl::getHeight(), TWebControl::getStyle(), TWebControl::getTabIndex(), TWebControl::getTagName(), TWebControl::getToolTip(), TWebControl::getWidth(), TWebControl::render(), TWebControl::renderBeginTag(), TWebControl::renderContents(), TWebControl::renderEndTag(), TWebControl::setAccessKey(), TWebControl::setBackColor(), TWebControl::setBorderColor(), TWebControl::setBorderStyle(), TWebControl::setBorderWidth(), TWebControl::setCssClass(), TWebControl::setDisplay(), TWebControl::setForeColor(), TWebControl::setHeight(), TWebControl::setStyle(), TWebControl::setTabIndex(), TWebControl::setToolTip(), TWebControl::setWidth()
|
| Methods Inherited From TControl |
|
TControl::addedControl(), TControl::addParsedObject(), TControl::addToPostDataLoader(), TControl::applyStyleSheetSkin(), TControl::autoBindProperty(), TControl::autoDataBindProperties(), TControl::bindProperty(), TControl::broadcastEvent(), TControl::bubbleEvent(), TControl::clearChildState(), TControl::clearControlState(), TControl::clearNamingContainer(), TControl::clearViewState(), TControl::convertUniqueIdToClientId(), TControl::createChildControls(), TControl::createControlCollection(), TControl::dataBind(), TControl::dataBindChildren(), TControl::dataBindProperties(), TControl::ensureChildControls(), TControl::findControl(), TControl::findControlsByID(), TControl::findControlsByType(), TControl::focus(), TControl::getAdapter(), TControl::getAllowChildControls(), TControl::getAttribute(), TControl::getAttributes(), TControl::getChildControlsCreated(), TControl::getClientID(), TControl::getControls(), TControl::getControlStage(), TControl::getControlState(), TControl::getCustomData(), TControl::getEnabled(), TControl::getEnableTheming(), TControl::getEnableViewState(), TControl::getHasAdapter(), TControl::getHasAttributes(), TControl::getHasChildInitialized(), TControl::getHasControls(), TControl::getHasInitialized(), TControl::getHasLoaded(), TControl::getHasLoadedPostData(), TControl::getHasPreRendered(), TControl::getID(), TControl::getNamingContainer(), TControl::getPage(), TControl::getParent(), TControl::getRegisteredObject(), TControl::getSkinID(), TControl::getSourceTemplateControl(), TControl::getTemplateControl(), TControl::getUniqueID(), TControl::getViewState(), TControl::getVisible(), TControl::hasAttribute(), TControl::initRecursive(), TControl::isDescendentOf(), TControl::isObjectRegistered(), TControl::loadRecursive(), TControl::loadState(), TControl::loadStateRecursive(), TControl::onDataBinding(), TControl::onInit(), TControl::onLoad(), TControl::onPreRender(), TControl::onUnload(), TControl::preRenderRecursive(), TControl::raiseBubbleEvent(), TControl::registerObject(), TControl::removeAttribute(), TControl::removedControl(), TControl::render(), TControl::renderChildren(), TControl::renderControl(), TControl::saveState(), TControl::saveStateRecursive(), TControl::setAdapter(), TControl::setAttribute(), TControl::setChildControlsCreated(), TControl::setControlStage(), TControl::setControlState(), TControl::setCustomData(), TControl::setEnabled(), TControl::setEnableTheming(), TControl::setEnableViewState(), TControl::setID(), TControl::setPage(), TControl::setSkinID(), TControl::setTemplateControl(), TControl::setViewState(), TControl::setVisible(), TControl::trackViewState(), TControl::traverseChildControls(), TControl::unbindProperty(), TControl::unloadRecursive(), TControl::unregisterObject(), TControl::__get()
|
|