[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Web/UI/WebControls/ -> TDataList.php (sommaire)

TDataList class file

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: TDataList.php 1397 2006-09-07 07:55:53Z wei $
Poids: 1455 lignes (44 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 5 classes

TDataList:: (73 méthodes):
  getItems()
  getItemCount()
  getItemTemplate()
  setItemTemplate()
  getItemStyle()
  getAlternatingItemTemplate()
  setAlternatingItemTemplate()
  getAlternatingItemStyle()
  getSelectedItemTemplate()
  setSelectedItemTemplate()
  getSelectedItemStyle()
  getEditItemTemplate()
  setEditItemTemplate()
  getEditItemStyle()
  getHeaderTemplate()
  setHeaderTemplate()
  getHeaderStyle()
  getHeader()
  getFooterTemplate()
  setFooterTemplate()
  getFooterStyle()
  getFooter()
  getEmptyTemplate()
  setEmptyTemplate()
  getSeparatorTemplate()
  setSeparatorTemplate()
  getSeparatorStyle()
  getSelectedItemIndex()
  setSelectedItemIndex()
  getSelectedItem()
  getSelectedDataKey()
  getEditItemIndex()
  setEditItemIndex()
  getEditItem()
  getShowHeader()
  setShowHeader()
  getShowFooter()
  setShowFooter()
  getRepeatInfo()
  getCaption()
  setCaption()
  getCaptionAlign()
  setCaptionAlign()
  getRepeatColumns()
  setRepeatColumns()
  getRepeatDirection()
  setRepeatDirection()
  getRepeatLayout()
  setRepeatLayout()
  bubbleEvent()
  onItemCreated()
  onItemDataBound()
  onItemCommand()
  onEditCommand()
  onDeleteCommand()
  onUpdateCommand()
  onCancelCommand()
  getHasHeader()
  getHasFooter()
  getHasSeparators()
  generateItemStyle()
  renderItem()
  getItem()
  createItemInternal()
  createItem()
  applyItemStyles()
  initializeItem()
  saveState()
  loadState()
  reset()
  restoreItemsFromViewState()
  performDataBinding()
  render()

TDataListItemEventParameter:: (2 méthodes):
  __construct()
  getItem()

TDataListCommandEventParameter:: (3 méthodes):
  __construct()
  getItem()
  getCommandSource()

TDataListItem:: (8 méthodes):
  __construct()
  createStyle()
  getItemType()
  setItemType()
  getItemIndex()
  getDataItem()
  setDataItem()
  bubbleEvent()

TDataListItemCollection:: (1 méthode):
  insertAt()


Classe: TDataList  - X-Ref

TDataList class

TDataList represents a data bound and updatable list control.

The {@link setHeaderTemplate HeaderTemplate} property specifies the content
template that will be displayed at the beginning, while
{@link setFooterTemplate FooterTemplate} at the end.
If present, these two templates will only be rendered when the data list is
given non-empty data. In this case, for each data item the content defined
by {@link setItemTemplate ItemTemplate} will be generated and displayed once.
If {@link setAlternatingItemTemplate AlternatingItemTemplate} is not empty,
then the corresponding content will be displayed alternatively with that
in {@link setItemTemplate ItemTemplate}. The content in
{@link setSeparatorTemplate SeparatorTemplate}, if not empty, will be
displayed between items. Besides the above templates, there are two additional
templates, {@link setEditItemTemplate EditItemTemplate} and
{@link setSelectedItemTemplate SelectedItemTemplate}, which are used to display
items that are in edit and selected mode, respectively.

All these templates are associated with styles that may be applied to
the corresponding generated items. For example,
{@link getAlternatingItemStyle AlternatingItemStyle} will be applied to
every alternating item in the data list.

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, {@link getItemStyle ItemStyle}, {@link getAlternatingItemStyle AlternatingItemStyle},
{@link getSelectedItemStyle SelectedItemStyle}, and {@link getEditItemStyle EditItemStyle}.
Therefore, if background color is set as red in {@link getItemStyle ItemStyle},
{@link getEditItemStyle EditItemStyle} will also have red background color
unless it is set to a different value explicitly.

To change the status of a particular item, set {@link setSelectedItemIndex SelectedItemIndex}
or {@link setEditItemIndex EditItemIndex}. The former will change the indicated
item to selected mode, which will cause the item to use {@link setSelectedItemTemplate SelectedItemTemplate}
for presentation. The latter will change the indicated item to edit mode.
Note, if an item is in edit mode, then selecting this item will have no effect.

The layout of the data items in the list is specified via
{@link setRepeatLayout RepeatLayout}, which can be either 'Table' (default) or 'Flow'.
A table layout uses HTML table cells to organize the data items while
a flow layout uses line breaks to organize the data items.
When the layout is using 'Table', {@link setCellPadding CellPadding} and
{@link setCellSpacing CellSpacing} can be used to adjust the cellpadding and
cellpadding of the table, and {@link setCaption Caption} and {@link setCaptionAlign CaptionAlign}
can be used to add a table caption with the specified alignment.

The number of columns used to display the data items is specified via
{@link setRepeatColumns RepeatColumns} property, while the {@link setRepeatDirection RepeatDirection}
governs the order of the items being rendered.

You can retrive the repeated contents by the {@link getItems Items} property.
The header and footer items can be accessed by {@link getHeader Header}
and {@link getFooter Footer} properties, respectively.

When TDataList creates an item, it will raise an {@link onItemCreated OnItemCreated}
so that you may customize the newly created item.
When databinding is performed by TDataList, for each item once it has finished
databinding, an {@link onItemDataBound OnItemDataBound} event will be raised.

When an item is selected by an end-user, a {@link onSelectedIndexChanged OnSelectedIndexChanged}
event will be raised. Note, the selected index may not be actually changed.
The event mainly informs the server side that the end-user has made a selection.

Each datalist item has a {@link TDataListItem::getItemType type}
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.

TDataList raises an {@link onItemCommand OnItemCommand} whenever a button control
within some TDataList item raises a <b>OnCommand</b> event. If the command name
is one of the followings: 'edit', 'update', 'select', 'delete', 'cancel' (case-insensitive),
another event will also be raised. For example, if the command name is 'edit',
then the new event is {@link onEditCommand OnEditCommand}.

Note, the data bound to the datalist are reset to null after databinding.
There are several ways to access the data associated with a datalist item:
- Access the data in {@link onItemDataBound OnItemDataBound} event
- Use {@link getDataKeys DataKeys} to obtain the data key associated with
the specified datalist item 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.

getItems()   X-Ref

return: TDataListItemCollection item list

getItemCount()   X-Ref

return: integer number of items

getItemTemplate()   X-Ref

return: ITemplate the template for item

setItemTemplate($value)   X-Ref

param: ITemplate the template for item

getItemStyle()   X-Ref

return: TTableItemStyle the style for item

getAlternatingItemTemplate()   X-Ref

return: ITemplate the template for each alternating item

setAlternatingItemTemplate($value)   X-Ref

param: ITemplate the template for each alternating item

getAlternatingItemStyle()   X-Ref

return: TTableItemStyle the style for each alternating item

getSelectedItemTemplate()   X-Ref

return: ITemplate the selected item template

setSelectedItemTemplate($value)   X-Ref

param: ITemplate the selected item template

getSelectedItemStyle()   X-Ref

return: TTableItemStyle the style for selected item

getEditItemTemplate()   X-Ref

return: ITemplate the edit item template

setEditItemTemplate($value)   X-Ref

param: ITemplate the edit item template

getEditItemStyle()   X-Ref

return: TTableItemStyle the style for edit item

getHeaderTemplate()   X-Ref

return: ITemplate the header template

setHeaderTemplate($value)   X-Ref

param: ITemplate the header template

getHeaderStyle()   X-Ref

return: TTableItemStyle the style for header

getHeader()   X-Ref

return: TDataListItem the header item

getFooterTemplate()   X-Ref

return: ITemplate the footer template

setFooterTemplate($value)   X-Ref

param: ITemplate the footer template

getFooterStyle()   X-Ref

return: TTableItemStyle the style for footer

getFooter()   X-Ref

return: TDataListItem the footer item

getEmptyTemplate()   X-Ref

return: ITemplate the template applied when no data is bound to the datalist

setEmptyTemplate($value)   X-Ref

param: ITemplate the template applied when no data is bound to the datalist

getSeparatorTemplate()   X-Ref

return: ITemplate the separator template

setSeparatorTemplate($value)   X-Ref

param: ITemplate the separator template

getSeparatorStyle()   X-Ref

return: TTableItemStyle the style for separator

getSelectedItemIndex()   X-Ref

return: integer the zero-based index of the selected item in {@link getItems Items}.

setSelectedItemIndex($value)   X-Ref
Selects an item by its index in {@link getItems Items}.
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.

param: integer the selected item index

getSelectedItem()   X-Ref

return: TDataListItem the selected item, null if no item is selected.

getSelectedDataKey()   X-Ref

return: mixed the key value of the currently selected item

getEditItemIndex()   X-Ref

return: integer the zero-based index of the edit item in {@link getItems Items}.

setEditItemIndex($value)   X-Ref
Edits an item by its index in {@link getItems Items}.
Previously editting item will change to normal item state.
If the index is less than 0, any existing edit item will be cleared up.

param: integer the edit item index

getEditItem()   X-Ref

return: TDataListItem the edit item

getShowHeader()   X-Ref

return: boolean whether the header should be shown. Defaults to true.

setShowHeader($value)   X-Ref

param: boolean whether to show header

getShowFooter()   X-Ref

return: boolean whether the footer should be shown. Defaults to true.

setShowFooter($value)   X-Ref

param: boolean whether to show footer

getRepeatInfo()   X-Ref

return: TRepeatInfo repeat information (primarily used by control developers)

getCaption()   X-Ref

return: string caption of the table layout

setCaption($value)   X-Ref

param: string caption of the table layout

getCaptionAlign()   X-Ref

return: TTableCaptionAlign alignment of the caption of the table layout. Defaults to TTableCaptionAlign::NotSet.

setCaptionAlign($value)   X-Ref

return: TTableCaptionAlign alignment of the caption of the table layout.

getRepeatColumns()   X-Ref

return: integer the number of columns that the list should be displayed with. Defaults to 0 meaning not set.

setRepeatColumns($value)   X-Ref

param: integer the number of columns that the list should be displayed with.

getRepeatDirection()   X-Ref

return: TRepeatDirection the direction of traversing the list, defaults to TRepeatDirection::Vertical

setRepeatDirection($value)   X-Ref

param: TRepeatDirection the direction of traversing the list

getRepeatLayout()   X-Ref

return: TRepeatLayout how the list should be displayed, using table or using line breaks. Defaults to TRepeatLayout::Table.

setRepeatLayout($value)   X-Ref

param: TRepeatLayout how the list should be displayed, using table or using line breaks

bubbleEvent($sender,$param)   X-Ref
This method overrides parent's implementation to handle
{@link onItemCommand OnItemCommand} event which is bubbled from
{@link TDataListItem} child controls.
If the event parameter is {@link TDataListCommandEventParameter} 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 {@link onEditCommand OnEditCommand}).
This method should only be used by control developers.

param: TControl the sender of the event
param: TEventParameter event parameter
return: boolean whether the event bubbling should stop here.

onItemCreated($param)   X-Ref
Raises <b>OnItemCreated</b> event.
This method is invoked after a data list item is created and instantiated with
template, but before added to the page hierarchy.
The {@link TDataListItem} control responsible for the event
can be determined from the event parameter.
If you override this method, be sure to call parent's implementation
so that event handlers have chance to respond to the event.

param: TDataListItemEventParameter event parameter

onItemDataBound($param)   X-Ref
Raises <b>OnItemDataBound</b> event.
This method is invoked right after an item is data bound.
The {@link TDataListItem} control responsible for the event
can be determined from the event parameter.
If you override this method, be sure to call parent's implementation
so that event handlers have chance to respond to the event.

param: TDataListItemEventParameter event parameter

onItemCommand($param)   X-Ref
Raises <b>OnItemCommand</b> event.
This method is invoked when a child control of the data list
raises an <b>Command</b> event.

param: TDataListCommandEventParameter event parameter

onEditCommand($param)   X-Ref
Raises <b>OnEditCommand</b> event.
This method is invoked when a child control of the data list
raises an <b>Command</b> event and the command name is 'edit' (case-insensitive).

param: TDataListCommandEventParameter event parameter

onDeleteCommand($param)   X-Ref
Raises <b>OnDeleteCommand</b> event.
This method is invoked when a child control of the data list
raises an <b>Command</b> event and the command name is 'delete' (case-insensitive).

param: TDataListCommandEventParameter event parameter

onUpdateCommand($param)   X-Ref
Raises <b>OnUpdateCommand</b> event.
This method is invoked when a child control of the data list
raises an <b>Command</b> event and the command name is 'update' (case-insensitive).

param: TDataListCommandEventParameter event parameter

onCancelCommand($param)   X-Ref
Raises <b>OnCancelCommand</b> event.
This method is invoked when a child control of the data list
raises an <b>Command</b> event and the command name is 'cancel' (case-insensitive).

param: TDataListCommandEventParameter event parameter

getHasHeader()   X-Ref
Returns a value indicating whether this control contains header item.
This method is required by {@link IRepeatInfoUser} interface.

return: boolean always false.

getHasFooter()   X-Ref
Returns a value indicating whether this control contains footer item.
This method is required by {@link IRepeatInfoUser} interface.

return: boolean always false.

getHasSeparators()   X-Ref
Returns a value indicating whether this control contains separator items.
This method is required by {@link IRepeatInfoUser} interface.

return: boolean always false.

generateItemStyle($itemType,$index)   X-Ref
Returns a style used for rendering items.
This method is required by {@link IRepeatInfoUser} interface.

param: string item type (Header,Footer,Item,AlternatingItem,SelectedItem,EditItem,Separator,Pager)
param: integer index of the item being rendered
return: TStyle item style

renderItem($writer,$repeatInfo,$itemType,$index)   X-Ref
Renders an item in the list.
This method is required by {@link IRepeatInfoUser} interface.

param: THtmlWriter writer for rendering purpose
param: TRepeatInfo repeat information
param: string item type (Header,Footer,Item,AlternatingItem,SelectedItem,EditItem,Separator,Pager)
param: integer zero-based index of the item in the item list

getItem($itemType,$index)   X-Ref

param: string item type
param: integer item index
return: TDataListItem data list item with the specified item type and index

createItemInternal($itemIndex,$itemType,$dataBind,$dataItem)   X-Ref
Creates a data list item and does databinding if needed.
This method invokes {@link createItem} to create a new data list item.

param: integer zero-based item index.
param: TListItemType item type
param: boolean whether to do databinding for the item
param: mixed data to be associated with the item
return: TDataListItem the created item

createItem($itemIndex,$itemType)   X-Ref
Creates a DataList item instance based on the item type and index.

param: integer zero-based item index
param: TListItemType item type
return: TDataListItem created data list item

applyItemStyles()   X-Ref
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, {@link getItemStyle ItemStyle}, {@link getAlternatingItemStyle AlternatingItemStyle},
{@link getSelectedItemStyle SelectedItemStyle}, and {@link getEditItemStyle EditItemStyle}.
Therefore, if background color is set as red in {@link getItemStyle ItemStyle},
{@link getEditItemStyle EditItemStyle} will also have red background color
unless it is set to a different value explicitly.


initializeItem($item)   X-Ref
Initializes a data list item.
The item is added as a child of the data list and the corresponding
template is instantiated within the item.

param: TDataListItem item to be initialized

saveState()   X-Ref
Saves item count in viewstate.
This method is invoked right before control state is to be saved.


loadState()   X-Ref
Loads item count information from viewstate.
This method is invoked right after control state is loaded.


reset()   X-Ref
Clears up all items in the data list.


restoreItemsFromViewState()   X-Ref
Creates data list items based on viewstate information.


performDataBinding($data)   X-Ref
Performs databinding to populate data list items from data source.
This method is invoked by dataBind().
You may override this function to provide your own way of data population.

param: Traversable the data

render($writer)   X-Ref
Renders the data list control.
This method overrides the parent implementation.

param: THtmlWriter writer for rendering purpose.

Classe: TDataListItemEventParameter  - X-Ref

TDataListItemEventParameter class

TDataListItemEventParameter encapsulates the parameter data for
{@link TDataList::onItemCreated ItemCreated} event of {@link TDataList} controls.
The {@link getItem Item} property indicates the DataList item related with the event.

__construct(TDataListItem $item)   X-Ref
Constructor.

param: TDataListItem DataList item related with the corresponding event

getItem()   X-Ref

return: TDataListItem DataList item related with the corresponding event

Classe: TDataListCommandEventParameter  - X-Ref

TDataListCommandEventParameter class

TDataListCommandEventParameter encapsulates the parameter data for
{@link TDataList::onItemCommand ItemCommand} event of {@link TDataList} controls.

The {@link getItem Item} property indicates the DataList item related with the event.
The {@link getCommandSource CommandSource} refers to the control that originally
raises the Command event.

__construct($item,$source,TCommandEventParameter $param)   X-Ref
Constructor.

param: TDataListItem DataList item responsible for the event
param: TControl original event sender
param: TCommandEventParameter original event parameter

getItem()   X-Ref

return: TDataListItem the TDataListItem control responsible for the event.

getCommandSource()   X-Ref

return: TControl the control originally raises the <b>Command</b> event.

Classe: TDataListItem  - X-Ref

TDataListItem class

A TDataListItem control represents an item in the {@link TDataList} control,
such as heading section, footer section, or a data item.
The index and data value of the item can be accessed via {@link getItemIndex ItemIndex}>
and {@link getDataItem DataItem} properties, respectively. The type of the item
is given by {@link getItemType ItemType} property.

__construct($itemIndex,$itemType)   X-Ref
Constructor.

param: integer zero-based index of the item in the item collection of DataList
param: TListItemType item type

createStyle()   X-Ref
Creates a style object for the control.
This method creates a {@link TTableItemStyle} to be used by a datalist item.

return: TStyle control style to be used

getItemType()   X-Ref

return: TListItemType item type

setItemType($value)   X-Ref

param: TListItemType item type.

getItemIndex()   X-Ref

return: integer zero-based index of the item in the item collection of DataList

getDataItem()   X-Ref

return: mixed data associated with the item

setDataItem($value)   X-Ref

param: mixed data to be associated with the item

bubbleEvent($sender,$param)   X-Ref
This method overrides parent's implementation by wrapping event parameter
for <b>Command</b> event with item information.

param: TControl the sender of the event
param: TEventParameter event parameter
return: boolean whether the event bubbling should stop here.

Classe: TDataListItemCollection  - X-Ref

TDataListItemCollection class.

TDataListItemCollection represents a collection of data list items.

insertAt($index,$item)   X-Ref
Inserts an item at the specified position.
This overrides the parent implementation by inserting only TDataListItem.

param: integer the speicified position.
param: mixed new item



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7