From 2a962765f0b687988384294cdb4baf51e291680c Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 6 Feb 2007 22:44:55 +0000 Subject: updated QS pages. --- .../protected/pages/Configurations/Templates1.page | 17 +++-- .../protected/pages/Controls/Repeater.page | 83 ++++++++++++++++------ .../pages/GettingStarted/NewFeatures.page | 6 +- 3 files changed, 77 insertions(+), 29 deletions(-) (limited to 'demos/quickstart') diff --git a/demos/quickstart/protected/pages/Configurations/Templates1.page b/demos/quickstart/protected/pages/Configurations/Templates1.page index 34ffc975..9a71d6a5 100644 --- a/demos/quickstart/protected/pages/Configurations/Templates1.page +++ b/demos/quickstart/protected/pages/Configurations/Templates1.page @@ -34,19 +34,24 @@ Note, property names and event names are all case-insensitive, while component t Also note, initial values for properties whose name ends with Template are specially processed. In particular, the initial values are parsed as TTemplate objects. The ItemTemplate property of the TRepeater control is such an example.

-To deal conveniently with properties taking take big trunk of initial data, the following property initialization tag is introduced, +To facilitate initializing properties with big trunk of data, the following property initialization tag is introduced. It is equivalent to ...PropertyName="PropertyValue"... in every aspect. Property initialization tags must be directly enclosed between the corresponding opening and closing component tag. +

<prop:PropertyName> PropertyValue </prop:PropertyName> -It is equivalent to ...PropertyName="PropertyValue"... in every aspect. Property initialization tags must be directly enclosed between the corresponding opening and closing component tag. +

+Since version 3.1.0, the property initialization tag can also be used to initialize a set of subproperties who share the same parent property. For example, the following is equivalent to HeaderStyle.BackColor="black" and HeaderStyle.ForeColor="red".

+ +<prop:HeaderStyle BackColor="black" ForeColor="red" /> +

Component IDs

When specified in templates, component ID property has special meaning in addition to its normal property definition. A component tag specified with an ID value in template will register the corresponding component to the template owner control. The component can thus be directly accessed from the template control with its ID value. For example, in Home page's template, the following component tag - + <com:TTextBox ID="TextBox" Text="First Name" /> makes it possible to get the textbox object in code using $page->TextBox. @@ -55,7 +60,7 @@ makes it possible to get the textbox object in code using $page->TextBox

Template Control Tags

A template control tag is used to configure the initial property values of the control owning the template. Its format is as follows, - + <%@ PropertyName="PropertyValue" ... %> Like in component tags, PropertyName is case-insensitive and can be a property or subproperty name. @@ -72,7 +77,7 @@ Template control tag is optional in a template. Each template can contain at mos

Comment tags are used to put in a template developer comments that will not display to end-users. Contents enclosed within a comment tag will be treated as raw text strings and PRADO will not attempt to parse them. Comment tags cannot be used within property values. The format of comment tags is as follows,

- + <!-- Comments INVISIBLE to end-users ---> @@ -84,7 +89,7 @@ The new comment tag <!-- ... ---> has been introduced since PRADO

Since version 3.0.5, PRADO starts to support external template inclusion. This is accomplished via include tags, where external template files are specified in namespace format and their file name must be terminated as .tpl.

- + <%include path.to.templateFile %> diff --git a/demos/quickstart/protected/pages/Controls/Repeater.page b/demos/quickstart/protected/pages/Controls/Repeater.page index cc642c5a..69c6cdba 100644 --- a/demos/quickstart/protected/pages/Controls/Repeater.page +++ b/demos/quickstart/protected/pages/Controls/Repeater.page @@ -1,20 +1,39 @@

TRepeater

+

-TRepeater displays its content defined in templates repeatedly based on the given data specified by the DataSource or DataSourceID property. The repeated contents can be retrieved from the Items property. Each item is created by instantiating a template and each is a child control of the repeater. +TRepeater displays its content repeatedly based on the data fetched from DataSource. The repeated contents in TRepeater are called items which are controls accessible through Items property. When dataBind() is invoked, TRepeater creates an item for each row of data and binds the data row to the item. Optionally, a repeater can have a header, a footer and/or separators between items.

+

-Like normal control templates, the repeater templates can contain static text, controls and special tags, which after instantiation, become child contents of the corresponding item. TRepeater defines five templates for different purposes, +The layout of the repeated contents are specified by inline templates. In particular, repeater items, header, footer, etc. are being instantiated with the corresponding templates when data is being bound to the repeater. +

+ +

+Since v3.1.0, the layout can also be specified by renderers. A renderer is a control class that can be instantiated as repeater items, header, etc. A renderer can thus be viewed as an external template (in fact, it can also be non-templated controls). A renderer can be any control class. If implemented with one of the following interfaces, a renderer will be initialized with additional properties relevant to the repeater items:

+
    -
  • HeaderTemplate - the template used for displaying content at the beginning of a repeater;
  • -
  • FooterTemplate - the template used for displaying content at the end of a repeater;
  • -
  • ItemTemplate - the template used for displaying every repeater item. If AlternatingItemTemplate is also defined, ItemTemplate will be used for displaying item 1, 3, 5, etc.
  • -
  • AlternatingItemTemplate - the template used for displaying every alternating repeater item (i.e., item 2, 4, 6, etc.)
  • -
  • SeparatorTemplate - the template used for displaying content between items.
  • +
  • IDataRenderer - the Data property will be set as the row of the data bound to the repeater item. Many PRADO controls implement this interface, such as TLabel, TTextBox, etc.
  • +
  • IItemDataRenderer - the ItemIndex property will be set as the zero-based index of the item in the repeater item collection, and the ItemType property as the item's type (such as TListItemType::Item). As a convenient base class, TRepeaterItemRenderer implements IDataItemRenderer and can have an associated template because it extends from TTemplateControl.
-

+ + +

+The following properties are used to specify different types of template and renderer for a repeater. If an item type is defined with both a template and a renderer, the latter takes precedence. +

+
    +
  • ItemTemplate, ItemRenderer - for each repeated row of data.
  • +
  • AlternatingItemTemplate, AlternatingItemRenderer: for each alternating row of data. If not set, ItemTemplate or ItemRenderer will be used instead, respectively.
  • +
  • HeaderTemplate, HeaderRenderer - for the repeater header.
  • +
  • FooterTemplate, FooterRenderer - for the repeater footer.
  • +
  • SeparatorTemplate, SeparatorRenderer - for content to be displayed between items.
  • +
  • EmptyTemplate, EmptyRenderer - used when data bound to the repeater is empty.
  • +
+ + +

To populate data into the repeater items, set DataSource to a valid data object, such as array, TList, TMap, or a database table, and then call dataBind() for the repeater. That is,

@@ -28,32 +47,54 @@ class MyPage extends TPage { } } -

-Normally, you only need to do this when the page containing the repeater is initially requested. In postbacks, TRepeater is smart enough to remember the previous state, i.e., contents populated with datasource information.The following sample displays tabular data using TRepeater. + +

+When dataBind() is called, TRepeater undergoes the following lifecycles for each row of data:

-

-TRepeater provides several events to facilitate manipulation of its items, + +

    +
  1. create item based on templates or renderers
  2. +
  3. set the row of data to the item
  4. +
  5. raise an OnItemCreated event
  6. +
  7. add the item as a child control
  8. +
  9. call dataBind() of the item
  10. +
  11. raise an OnItemDataBound event
  12. +
+ +

+Normally, you only need to bind the data to repeater when the page containing the repeater is initially requested. When the page is post back, the repeater will restore automatically all its contents, including items, header, footer and separators. However, the data row associated with each item will not be recovered and thus become null.

-
    -
  • OnItemCreated - raised each time an item is newly created. When the event is raised, data and child controls are both available for the new item.
  • -
  • OnItemDataBound - raised each time an item just completes databinding. When the event is raised, data and child controls are both available for the item, and the item has finished databindings of itself and all its child controls.
  • -
  • OnItemCommand - raised when a child control of some item (such as a TButton) raises an OnCommand event.
  • + +

    +To access the repeater item data in postbacks, use one of the following ways: +

    +
      +
    • Use DataKeys to obtain the data key associated with the specified repeater item and use the key to fetch the corresponding data from some persistent storage such as DB.
    • +
    • Save the whole dataset in viewstate, which will restore the dataset automatically upon postback. Be aware though, if the size of your dataset is big, your page size will become big. Some complex data may also have serializing problem if saved in viewstate.
    -

    + + +

    +TRepeater raises an OnItemCommand event whenever a button control within some repeater item raises a OnCommand event. Therefore, +you can handle all sorts of OnCommand event in a central place by +writing an event handler for OnItemCommand. +

    + +

    The following example shows how to use TRepeater to display tabular data.

    -

    +

    TRepeater can be used in more complex situations. As an example, we show in the following how to use nested repeaters, i.e., repeater in repeater. This is commonly seen in presenting master-detail data. To use a repeater within another repeater, for an item for the outer repeater is created, we need to set the detail data source for the inner repeater. This can be achieved by responding to the OnItemDataBound event of the outer repeater. An OnItemDataBound event is raised each time an outer repeater item completes databinding. In the following example, we exploit another event of repeater called OnItemCreated, which is raised each time a repeater item (and its content) is newly created. We respond to this event by setting different background colors for repeater items to achieve alternating item background display. This saves us from writing an AlternatingItemTemplate for the repeaters.

    -

    +

    Besides displaying data, TRepeater can also be used to collect data from users. Validation controls can be placed in TRepeater templates to verify that user inputs are valid.

    -

    +

    The PRADO component composer demo is a good example of such usage. It uses a repeater to collect the component property and event definitions. Users can also delete or adjust the order of the properties and events, which is implemented by responding to the OnItemCommand event of repeater.

    -

    +

    See in the following yet another example showing how to use repeater to collect user inputs.

    diff --git a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page index 781eb0fa..ca1f361f 100644 --- a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page +++ b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page @@ -14,8 +14,10 @@ This page summarizes the main new features that are introduced in each PRADO rel
  • Layered database support -
  • New controls, modules and services - TSoapService, TOutputCache, TSessionPageStatePersister, TFeedService, TJsonService, cache dependency classes, TXmlTransform
  • -
  • Configure subproperties in a group
  • -
  • Item renderer feature for TRepeater, TDataList and TDataGrid
  • + +
  • New template syntax facilitating subproperty configuration.
  • + +
  • Introduction of renderer concept - renderer enables reusing item templates that are commonly found in TRepeater, TDataList and TDataGrid, and makes the configuration on these controls much cleaner. For more details about renders, see the updated tutorials on TRepeater, TDataList and TDataGrid.
$Id$
-- cgit v1.2.3