From 1cd5380675aab9a2884845b6630091be2e857f69 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Thu, 18 May 2006 21:26:25 +0000
Subject: Merge from 3.0 branch till 1082.
---
.../protected/pages/Advanced/Collections.page | 135 +++++++++++++++++++++
1 file changed, 135 insertions(+)
create mode 100644 demos/quickstart/protected/pages/Advanced/Collections.page
(limited to 'demos/quickstart/protected/pages')
diff --git a/demos/quickstart/protected/pages/Advanced/Collections.page b/demos/quickstart/protected/pages/Advanced/Collections.page
new file mode 100644
index 00000000..181dc556
--- /dev/null
+++ b/demos/quickstart/protected/pages/Advanced/Collections.page
@@ -0,0 +1,135 @@
+
+Collection is a basic data structure in programming. In traditional PHP programming, array is used widely to represent collection data structure. A PHP array is a mix of cardinal-indxed array and hash table.
+
+To enable object-oriented manipulation of collections, PRADO provides a set of powerful collection classes. Among them, the TList and TMap are the most fundamental and usually serve as the base classes for other collection classes. Since many PRADO components have properties that are of collection type, it is very important for developers to master the usage of PRADO collection classes.
+
+A TList object represents a cardinal-indexed array, i.e., an array (object) with the index 0, 1, 2, ...
+
+TList may be used like a PHP array. For example,
+
+To obtain the number of items in the list, use the Count property. Note, do not use count($list), as it always returns 1.
+
+In addition, TList implements a few commonly used convenient methods for manipulating the data in a list. These include
+
+As aforementioned, many PRADO component properties are based on TList or TList-derived collection classes. These properties all share the above usages.
+
+For example, TControl (the base class for all PRADO controls) has a property called Controls which represents the collection of child controls. The type of Controls is TControlCollection which extends TList. Therefore, to append a new child control, we can use the following,
+
+To traverse through the child controls, we can use,
+
+Another example is the Items property, available in list controls, TRepeater, TDataList and TDataGrid. In these controls, the ancestor class of Items is TList.
+
+Often, we want to extend TList to perform additional operations for each addition or removal of an item. The only methods that the child class needs to override are insertAt() and removeAt(). For example, to ensure the list only contains items that are of TControl type, we can override insertAt() as follows,
+
+A TMap object represents a hash table (or we say string-indexed array).
+
+Similar to TList, TMap may be used like an array,
+
+The Count property gives the number of items in the map while the Keys property returns a list of keys used in the map.
+
+The following methods are provided by TMap for convenience,
+
+TAttributeCollection is a special class extending from TMap. It is mainly used by the Attributes property of TControl.
+Collections
+Using TList
+
+
+
+Using TList-based component properties
+Extending TList
+Using TMap
+
+
+
+Using of TAttributeCollection
+
+Note, in the above $collection does NOT have a Label property. +
++Unlike TMap, keys in TAttributeCollection are case-insensitive. Therefore, $collection->Label is equivalent to $collection->LABEL. +
++Because of the above new features, when dealing with the Attributes property of controls, we may take advantage of the subproperty concept and configure control attribute values in a template as follows, +
++which adds an attribute named onclick to the TButton control. +
+ \ No newline at end of file -- cgit v1.2.3