- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

Packages: default System System.Caching System.Collections System.Data System.Data.ActiveRecord System.Data.ActiveRecord.Relations System.Data.ActiveRecord.Scaffold System.Data.ActiveReecord.Scaffold.InputBuilder System.Data.Commom.Sqlite System.Data.Common System.Data.Common.Mssql System.Data.Common.Mysql System.Data.Common.Oracle System.Data.Common.Pgsql System.Data.Common.Sqlite System.Data.DataGateway System.Data.SqlMap System.Data.SqlMap.Configuration System.Data.SqlMap.Statements System.Exceptions System.I18N System.IO System.Security System.Util System.Web System.Web.Services System.Web.UI System.Web.UI.ActiveControls System.Web.UI.WebControls System.Web.UI.WebControls.assets System.Xml Classes: IDataSource IItemDataRenderer IRepeatInfoUser TActiveFileUpload TBaseDataList TBaseValidator TBoundColumn TBulletedList TBulletedListDisplayMode TBulletedListEventParameter TBulletStyle TButton TButtonColumn TButtonColumnType TButtonType TCaptcha TCaptchaValidator TCheckBox TCheckBoxColumn TCheckBoxList TCircleHotSpot TClientScript TClientScriptLoader TClientSideValidationSummaryOptions TColorPicker TColorPickerClientSide TColorPickerMode TCompareValidator TCompleteWizardStep TConditional TContent TContentDirection TContentPlaceHolder TCustomValidator TDataBoundControl TDataGrid TDataGridColumn TDataGridColumnCollection TDataGridCommandEventParameter TDataGridItem TDataGridItemCollection TDataGridItemEventParameter TDataGridItemRenderer TDataGridPageChangedEventParameter TDataGridPager TDataGridPagerButtonType TDataGridPagerEventParameter TDataGridPagerMode TDataGridPagerPosition TDataGridPagerStyle TDataGridSortCommandEventParameter TDataList TDataListCommandEventParameter TDataListItem TDataListItemCollection TDataListItemEventParameter TDataListItemRenderer TDataRenderer TDataSourceControl TDataSourceSelectParameters TDataSourceView TDataTypeValidator TDatePicker TDatePickerClientScript TDatePickerInputMode TDatePickerMode TDatePickerPositionMode TDisplayStyle TDraggable TDropContainer TDropDownList TDropDownListColumn TEditCommandColumn TEmailAddressValidator TExpression TFileUpload TFont THiddenField THorizontalAlign THotSpot THotSpotCollection THotSpotMode THtmlArea THtmlElement THyperLink THyperLinkColumn TImage TImageButton TImageClickEventParameter TImageMap TImageMapEventParameter TInlineFrame TInlineFrameAlign TInlineFrameScrollBars TItemDataRenderer TJavascriptLogger TKeyboard TLabel TLinkButton TListBox TListControl TListControlValidator TListItem TListItemCollection TListItemType TListSelectionMode TLiteral TLiteralColumn TMarkdown TMetaTag TMetaTagCollection TMultiView TOutputCache TOutputCacheCalculateKeyEventParameter TOutputCacheCheckDependencyEventParameter TPager TPagerButtonType TPagerMode TPagerPageChangedEventParameter TPanel TPanelStyle TPlaceHolder TPolygonHotSpot TRadioButton TRadioButtonList TRangeValidationDataType TRangeValidator TRatingList TReadOnlyDataSource TReadOnlyDataSourceView TRectangleHotSpot TRegularExpressionValidator TRepeatDirection TRepeater TRepeaterCommandEventParameter TRepeaterItem TRepeaterItemCollection TRepeaterItemEventParameter TRepeaterItemRenderer TRepeatInfo TRepeatLayout TRequiredFieldValidator TSafeHtml TScrollBars TServerValidateEventParameter TSlider TSliderClientScript TSliderDirection TStatements TStyle TStyleSheet TTable TTableCaptionAlign TTableCell TTableCellCollection TTableFooterRow TTableGridLines TTableHeaderCell TTableHeaderRow TTableHeaderScope TTableItemStyle TTableRow TTableRowCollection TTableRowSection TTableStyle TTabPanel TTabView TTabViewCollection TTemplateColumn TTemplatedWizardStep TTextAlign TTextBox TTextBoxAutoCompleteType TTextBoxMode TTextHighlighter TTextHighlighterLineNumberStyle TValidationCompareOperator TValidationDataType TValidationSummary TValidationSummaryDisplayMode TValidationSummaryDisplayStyle TValidatorClientSide TValidatorDisplayStyle TVerticalAlign TView TViewCollection TWebControl TWebControlAdapter TWizard TWizardFinishNavigationTemplate TWizardNavigationButtonStyle TWizardNavigationButtonType TWizardNavigationContainer TWizardNavigationEventParameter TWizardNavigationTemplate TWizardSideBarListItemTemplate TWizardSideBarTemplate TWizardStartNavigationTemplate TWizardStep TWizardStepCollection TWizardStepNavigationTemplate TWizardStepType TXmlTransform |
Keyword
# Class TDataGrid
    TComponent
       |
       --TApplicationComponent
          |
          --TControl
             |
             --TWebControl
                |
                --TDataBoundControl
                   |
                   --TBaseDataList
                      |
                      --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,
           <com:TDataGrid ...>
              <com:TBoundColumn .../>
              <com:TEditCommandColumn .../>
           </com:TDataGrid>
- Manually created in code. Columns can be manipulated via the setColumns property of the datagrid. For example,
          $column=new TBoundColumn;
          $datagrid->Columns[]=$column;
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: Access the data in OnItemDataBound event Use DataKeys to obtain the data key associated with 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. Since: 3.0 Author: Qiang Xue <qiang.xue@gmail.com>
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 | addParsedObject ( mixed $object) Adds objects parsed in template to datagrid.
protected void | applyItemStyles () Applies styles to items, header, footer and separators.
boolean | bubbleEvent ( TControl $sender, TEventParameter $param) This method overrides parent's implementation to handle onItemCommand event which is bubbled from TDataGridItem child controls.
protected void | buildNextPrevPager ( TDataGridPager $pager) Builds a next-prev pager
protected void | buildNumericPager ( TDataGridPager $pager) Builds a numeric pager
protected void | buildPager ( TDataGridPager $pager) Builds the pager content based on pager style.
protected TDataGridColumnCollection | createAutoColumns ( Traversable $dataSource) Automatically generates datagrid columns based on datasource schema
protected TDataGridItem | createItem ( integer $itemIndex, TListItemType $dataSourceIndex, mixed $itemType) 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 | createStyle () Creates a style object for the control.
boolean | getAllowSorting ()
TTableItemStyle | getAlternatingItemStyle ()
TDataGridColumnCollection | getAutoColumns ()
boolean | getAutoGenerateColumns ()
string | getBackImageUrl ()
TDataGridPager | getBottomPager ()
string | getCaption ()
TTableCaptionAlign | getCaptionAlign ()
TDataGridColumnCollection | getColumns ()
TDataGridItem | getEditItem ()
integer | getEditItemIndex ()
TTableItemStyle | getEditItemStyle ()
ITemplate | getEmptyTemplate ()
TDataGridItem | getFooter ()
TTableItemStyle | getFooterStyle ()
TDataGridItem | getHeader ()
TTableItemStyle | getHeaderStyle ()
integer | getItemCount ()
TDataGridItemCollection | getItems ()
TTableItemStyle | getItemStyle ()
TDataGridPagerStyle | getPagerStyle ()
TDataGridItem | getSelectedItem ()
integer | getSelectedItemIndex ()
TTableItemStyle | getSelectedItemStyle ()
boolean | getShowFooter ()
boolean | getShowHeader ()
TStyle | getTableBodyStyle ()
TStyle | getTableFootStyle ()
TStyle | getTableHeadStyle ()
protected string | getTagName ()
TDataGridPager | getTopPager ()
protected void | initializeItem ( TDataGrid $item, TDataGridColumnCollection $columns) Initializes a datagrid item and cells inside it
void | loadState () Loads item count information from viewstate.
void | onCancelCommand ( TDataGridCommandEventParameter $param) Raises OnCancelCommand event.
void | onDeleteCommand ( TDataGridCommandEventParameter $param) Raises OnDeleteCommand event.
void | onEditCommand ( TDataGridCommandEventParameter $param) Raises OnEditCommand event.
void | onItemCommand ( TDataGridCommandEventParameter $param) Raises OnItemCommand event.
void | onItemCreated ( TDataGridItemEventParameter $param) Raises OnItemCreated event.
void | onItemDataBound ( TDataGridItemEventParameter $param) Raises OnItemDataBound event.
void | onPageIndexChanged ( TDataGridPageChangedEventParameter $param) Raises OnPageIndexChanged event.
void | onPagerCreated ( TDataGridPagerEventParameter $param) Raises OnPagerCreated event.
void | onSortCommand ( TDataGridSortCommandEventParameter $param) Raises OnSortCommand event.
void | onUpdateCommand ( TDataGridCommandEventParameter $param) Raises OnUpdateCommand event.
protected void | performDataBinding ( Traversable $data) Performs databinding to populate datagrid items from data source.
void | render ( THtmlWriter $writer) Renders the datagrid.
void | renderBeginTag ( THtmlWriter $writer) Renders the openning tag for the datagrid control which will render table caption if present.
protected void | renderTable ( THtmlWriter $writer) Renders the tabular data.
void | reset () Clears up all items in the datagrid.
protected void | restoreGridFromViewState () Restores datagrid content from viewstate.
void | saveState () Saves item count in viewstate.
void | setAllowSorting ( boolean $value)
void | setAutoGenerateColumns ( boolean $value)
void | setBackImageUrl ( string $value)
void | setCaption ( string $value)
void | setCaptionAlign ( TTableCaptionAlign $value)
void | setEditItemIndex ( integer $value) Edits an item by its index in getItems.
void | setEmptyTemplate ( ITemplate $value)
void | setSelectedItemIndex ( integer $value) Selects an item by its index in getItems.
void | setShowFooter ( boolean $value)
void | setShowHeader ( boolean $value)
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()
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()
Constant Summary
string | CMD_CANCEL |
string | CMD_DELETE |
string | CMD_EDIT |
string | CMD_PAGE |
string | CMD_PAGE_NEXT |
string | CMD_PAGE_PREV |
string | CMD_SELECT | Command name that TDataGrid understands.
string | CMD_SORT |
string | CMD_UPDATE |
string | IT_ALTERNATINGITEM |
string | IT_EDITITEM |
string | IT_FOOTER |
string | IT_HEADER | datagrid item types
string | IT_ITEM |
string | IT_PAGER |
string | IT_SELECTEDITEM |
string | IT_SEPARATOR |
Method Details
## addParsedObject
public void addParsedObject | (mixed $object )
Adds objects parsed in template to datagrid. Datagrid columns are added into Columns collection.
Input
mixed | $object | object parsed in template
Output
Exception
## applyItemStyles
protected void applyItemStyles | ()
Applies styles to items, header, footer and separators. Item styles are applied in a hierarchical way. Style in higher hierarchy will inherit from styles in lower hierarchy. Starting from the lowest hierarchy, the item styles include item's own style, ItemStyle, AlternatingItemStyle, SelectedItemStyle, and EditItemStyle. Therefore, if background color is set as red in ItemStyle, EditItemStyle will also have red background color unless it is set to a different value explicitly.
Output
Exception
## bubbleEvent
public boolean bubbleEvent | (TControl $sender , TEventParameter $param )
This method overrides parent's implementation to handle onItemCommand event which is bubbled from TDataGridItem child controls. If the event parameter is TDataGridCommandEventParameter and the command name is a recognized one, which includes 'select', 'edit', 'delete', 'update', and 'cancel' (case-insensitive), then a corresponding command event is also raised (such as OnEditCommand). This method should only be used by control developers.
Input
TControl | $sender | the sender of the event
TEventParameter | $param | event parameter
Output
boolean | whether the event bubbling should stop here.
Exception
## buildNextPrevPager
protected void buildNextPrevPager | (TDataGridPager $pager )
Builds a next-prev pager
Input
TDataGridPager | $pager | the container for the pager
Output
Exception
## buildNumericPager
protected void buildNumericPager | (TDataGridPager $pager )
Builds a numeric pager
Input
TDataGridPager | $pager | the container for the pager
Output
Exception
## buildPager
protected void buildPager | (TDataGridPager $pager )
Builds the pager content based on pager style.
Input
TDataGridPager | $pager | the container for the pager
Output
Exception
## createAutoColumns
protected TDataGridColumnCollection createAutoColumns | (Traversable $dataSource )
Automatically generates datagrid columns based on datasource schema
Input
Traversable | $dataSource | data source bound to the datagrid
Output
Exception
## createItem
protected TDataGridItem createItem | (integer $itemIndex , TListItemType $dataSourceIndex , mixed $itemType )
Creates a datagrid item instance based on the item type and index.
Input
integer | $itemIndex | zero-based item index
TListItemType | $dataSourceIndex | item type
mixed | $itemType |
Output
TDataGridItem | created data list item
Exception
## createPagerButton
protected mixed createPagerButton | (string $buttonType , boolean $enabled , string $text , string $commandName , string $commandParameter )
Creates a pager button. Depending on the button type, a TLinkButton or a TButton may be created. If it is enabled (clickable), its command name and parameter will also be set. Derived classes may override this method to create additional types of buttons, such as TImageButton.
Input
string | $buttonType | button type, either LinkButton or PushButton
boolean | $enabled | whether the button should be enabled
string | $text | caption of the button
string | $commandName | CommandName corresponding to the OnCommand event of the button
string | $commandParameter | CommandParameter corresponding to the OnCommand event of the button
Output
mixed | the button instance
Exception
## createStyle
protected TTableStyle createStyle | ()
Creates a style object for the control. This method creates a TTableStyle to be used by datagrid.
Output
TTableStyle | control style to be used
Exception
## getAllowSorting
public boolean getAllowSorting | ()
Output
boolean | whether sorting is enabled. Defaults to false.
Exception
## getAlternatingItemStyle
public TTableItemStyle getAlternatingItemStyle | ()
Output
TTableItemStyle | the style for each alternating item
Exception
## getAutoColumns
public TDataGridColumnCollection getAutoColumns | ()
Output
TDataGridColumnCollection | automatically generated datagrid columns
Exception
## getAutoGenerateColumns
public boolean getAutoGenerateColumns | ()
Output
boolean | whether datagrid columns should be automatically generated. Defaults to true.
Exception
## getBackImageUrl
public string getBackImageUrl | ()
Output
string | the URL of the background image for the datagrid
Exception
## getBottomPager
public TDataGridPager getBottomPager | ()
Output
TDataGridPager | the pager displayed at the bottom of datagrid. It could be null if paging is disabled.
Exception
## getCaption
public string getCaption | ()
Output
string | caption for the datagrid
Exception
## getCaptionAlign
public TTableCaptionAlign getCaptionAlign | ()
Output
TTableCaptionAlign | datagrid caption alignment. Defaults to TTableCaptionAlign::NotSet.
Exception
## getColumns
public TDataGridColumnCollection getColumns | ()
Output
TDataGridColumnCollection | manually specified datagrid columns
Exception
## getEditItem
public TDataGridItem getEditItem | ()
Output
TDataGridItem | the edit item
Exception
## getEditItemIndex
public integer getEditItemIndex | ()
Output
integer | the zero-based index of the edit item in Items. A value -1 means no item is in edit mode.
Exception
## getEditItemStyle
public TTableItemStyle getEditItemStyle | ()
Output
TTableItemStyle | the style for edit item
Exception
## getEmptyTemplate
public ITemplate getEmptyTemplate | ()
Output
ITemplate | the template applied when no data is bound to the datagrid
Exception
## getFooter
public TDataGridItem getFooter | ()
Output
TDataGridItem | the footer item
Exception
## getFooterStyle
public TTableItemStyle getFooterStyle | ()
Output
TTableItemStyle | the style for footer
Exception
## getHeader
public TDataGridItem getHeader | ()
Output
TDataGridItem | the header item
Exception
## getHeaderStyle
public TTableItemStyle getHeaderStyle | ()
Output
TTableItemStyle | the style for header
Exception
## getItemCount
public integer getItemCount | ()
Output
integer | number of items
Exception
## getItems
public TDataGridItemCollection getItems | ()
Output
TDataGridItemCollection | datagrid item collection
Exception
## getItemStyle
public TTableItemStyle getItemStyle | ()
Output
TTableItemStyle | the style for every item
Exception
## getPagerStyle
public TDataGridPagerStyle getPagerStyle | ()
Output
TDataGridPagerStyle | the style for pager
Exception
## getSelectedItem
public TDataGridItem getSelectedItem | ()
Output
TDataGridItem | the selected item, null if no item is selected.
Exception
## getSelectedItemIndex
public integer getSelectedItemIndex | ()
Output
integer | the zero-based index of the selected item in Items. A value -1 means no item selected.
Exception
## getSelectedItemStyle
public TTableItemStyle getSelectedItemStyle | ()
Output
TTableItemStyle | the style for selected item
Exception
## getShowFooter
public boolean getShowFooter | ()
Output
boolean | whether the footer should be displayed. Defaults to false.
Exception
## getShowHeader
public boolean getShowHeader | ()
Output
boolean | whether the header should be displayed. Defaults to true.
Exception
## getTableBodyStyle
public TStyle getTableBodyStyle | ()
Output
TStyle | the style for tbody element, if any
Exception
## getTableFootStyle
public TStyle getTableFootStyle | ()
Output
TStyle | the style for tfoot element, if any
Exception
## getTableHeadStyle
public TStyle getTableHeadStyle | ()
Output
TStyle | the style for thead element, if any
Exception
## getTagName
protected string getTagName | ()
Output
string | tag name (table) of the datagrid
Exception
## getTopPager
public TDataGridPager getTopPager | ()
Output
TDataGridPager | the pager displayed at the top of datagrid. It could be null if paging is disabled.
Exception
## initializeItem
protected void initializeItem | (TDataGrid $item , TDataGridColumnCollection $columns )
Initializes a datagrid item and cells inside it
Input
TDataGrid | $item | datagrid item to be initialized
TDataGridColumnCollection | $columns | datagrid columns to be used to initialize the cells in the item
Output
Exception
## loadState
public void loadState | ()
Loads item count information from viewstate. This method is invoked right after control state is loaded.
Output
Exception
## onCancelCommand
public void onCancelCommand | (TDataGridCommandEventParameter $param )
Raises OnCancelCommand event. This method is invoked when a button control raises OnCommand event with cancel command name.
Input
TDataGridCommandEventParameter | $param | event parameter
Output
Exception
## onDeleteCommand
public void onDeleteCommand | (TDataGridCommandEventParameter $param )
Raises OnDeleteCommand event. This method is invoked when a button control raises OnCommand event with delete command name.
Input
TDataGridCommandEventParameter | $param | event parameter
Output
Exception
## onEditCommand
public void onEditCommand | (TDataGridCommandEventParameter $param )
Raises OnEditCommand event. This method is invoked when a button control raises OnCommand event with edit command name.
Input
TDataGridCommandEventParameter | $param | event parameter
Output
Exception
## onItemCommand
public void onItemCommand | (TDataGridCommandEventParameter $param )
Raises OnItemCommand event. This method is invoked when a button control raises OnCommand event.
Input
TDataGridCommandEventParameter | $param | event parameter
Output
Exception
## onItemCreated
public void onItemCreated | (TDataGridItemEventParameter $param )
Raises OnItemCreated event. This method is invoked right after a datagrid item is created and before added to page hierarchy.
Input
TDataGridItemEventParameter | $param | event parameter
Output
Exception
## onItemDataBound
public void onItemDataBound | (TDataGridItemEventParameter $param )
Raises OnItemDataBound event. This method is invoked for each datagrid item after it performs databinding.
Input
TDataGridItemEventParameter | $param | event parameter
Output
Exception
## onPageIndexChanged
public void onPageIndexChanged | (TDataGridPageChangedEventParameter $param )
Raises OnPageIndexChanged event. This method is invoked when current page is changed.
Input
TDataGridPageChangedEventParameter | $param | event parameter
Output
Exception
## onPagerCreated
public void onPagerCreated | (TDataGridPagerEventParameter $param )
Raises OnPagerCreated event. This method is invoked right after a datagrid pager is created and before added to page hierarchy.
Input
TDataGridPagerEventParameter | $param | event parameter
Output
Exception
## onSortCommand
public void onSortCommand | (TDataGridSortCommandEventParameter $param )
Raises OnSortCommand event. This method is invoked when a button control raises OnCommand event with sort command name.
Input
TDataGridSortCommandEventParameter | $param | event parameter
Output
Exception
## onUpdateCommand
public void onUpdateCommand | (TDataGridCommandEventParameter $param )
Raises OnUpdateCommand event. This method is invoked when a button control raises OnCommand event with update command name.
Input
TDataGridCommandEventParameter | $param | event parameter
Output
Exception
## performDataBinding
protected void performDataBinding | (Traversable $data )
Performs databinding to populate datagrid items from data source. This method is invoked by dataBind(). You may override this function to provide your own way of data population.
Input
Traversable | $data | the bound data
Output
Exception
## render
public void render | (THtmlWriter $writer )
Renders the datagrid.
Input
THtmlWriter | $writer | writer for the rendering purpose
Output
Exception
## renderBeginTag
public void renderBeginTag | (THtmlWriter $writer )
Renders the openning tag for the datagrid control which will render table caption if present.
Input
THtmlWriter | $writer | the writer used for the rendering purpose
Output
Exception
## renderTable
protected void renderTable | (THtmlWriter $writer )
Renders the tabular data.
Input
THtmlWriter | $writer | writer
Output
Exception
## reset
public void reset | ()
Clears up all items in the datagrid.
Output
Exception
## restoreGridFromViewState
protected void restoreGridFromViewState | ()
Restores datagrid content from viewstate.
Output
Exception
## saveState
public void saveState | ()
Saves item count in viewstate. This method is invoked right before control state is to be saved.
Output
Exception
## setAllowSorting
public void setAllowSorting | (boolean $value )
Input
boolean | $value | whether sorting is enabled
Output
Exception
## setAutoGenerateColumns
public void setAutoGenerateColumns | (boolean $value )
Input
boolean | $value | whether datagrid columns should be automatically generated
Output
Exception
## setBackImageUrl
public void setBackImageUrl | (string $value )
Input
string | $value | the URL of the background image for the datagrid
Output
Exception
## setCaption
public void setCaption | (string $value )
Input
string | $value | caption for the datagrid
Output
Exception
## setCaptionAlign
public void setCaptionAlign | (TTableCaptionAlign $value )
Input
TTableCaptionAlign | $value | datagrid caption alignment. Valid values include
Output
Exception
## setEditItemIndex
public void setEditItemIndex | (integer $value )
Edits an item by its index in getItems. Previously editting item will change to normal item state. If the index is less than 0, any existing edit item will be cleared up.
Input
integer | $value | the edit item index
Output
Exception
## setEmptyTemplate
public void setEmptyTemplate | (ITemplate $value )
Input
ITemplate | $value | the template applied when no data is bound to the datagrid
Output
Exception
throws | TInvalidDataTypeException if the input is not an ITemplate or not null.
## setSelectedItemIndex
public void setSelectedItemIndex | (integer $value )
Selects an item by its index in getItems. Previously selected item will be un-selected. If the item to be selected is already in edit mode, it will remain in edit mode. If the index is less than 0, any existing selection will be cleared up.
Input
integer | $value | the selected item index
Output
Exception
## setShowFooter
public void setShowFooter | (boolean $value )
Input
boolean | $value | whether the footer should be displayed
Output
Exception
## setShowHeader
public void setShowHeader | (boolean $value )
Input
boolean | $value | whether the header should be displayed
Output
Exception
Constant Details
### CMD_CANCEL #### Type: string #### Value: 'Cancel'
### CMD_DELETE #### Type: string #### Value: 'Delete'
### CMD_EDIT #### Type: string #### Value: 'Edit'
### CMD_PAGE #### Type: string #### Value: 'Page'
### CMD_PAGE_NEXT #### Type: string #### Value: 'Next'
### CMD_PAGE_PREV #### Type: string #### Value: 'Previous'
### CMD_SELECT Command name that TDataGrid understands. #### Type: string #### Value: 'Select'
### CMD_SORT #### Type: string #### Value: 'Sort'
### CMD_UPDATE #### Type: string #### Value: 'Update'
### IT_ALTERNATINGITEM #### Type: string #### Value: 'AlternatingItem'
### IT_EDITITEM #### Type: string #### Value: 'EditItem'
### IT_FOOTER #### Type: string #### Value: 'Footer'
### IT_HEADER datagrid item types #### Type: string #### Value: 'Header' Deprecated: deprecated since version 3.0.4. Use TListItemType constants instead.
### IT_ITEM #### Type: string #### Value: 'Item'
### IT_PAGER #### Type: string #### Value: 'Pager'
### IT_SELECTEDITEM #### Type: string #### Value: 'SelectedItem'
### IT_SEPARATOR #### Type: string #### Value: 'Separator'