diff options
author | xue <> | 2006-02-05 06:52:00 +0000 |
---|---|---|
committer | xue <> | 2006-02-05 06:52:00 +0000 |
commit | d13ef89849ad340f424084367fc8f16b03266bfd (patch) | |
tree | 4d93b788c6e2ea2490be77e62241061b2140cbeb /demos/quickstart | |
parent | 045b8b2a21873b8747fde66890b094f63c095c93 (diff) |
Completed DataGrid part II description.
Diffstat (limited to 'demos/quickstart')
-rw-r--r-- | demos/quickstart/protected/pages/Controls/DataGrid2.page | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/Controls/DataGrid2.page b/demos/quickstart/protected/pages/Controls/DataGrid2.page index 1a55c213..ed169b1a 100644 --- a/demos/quickstart/protected/pages/Controls/DataGrid2.page +++ b/demos/quickstart/protected/pages/Controls/DataGrid2.page @@ -49,5 +49,27 @@ To enable custom paging, set both <tt>AllowPaging</tt> and <tt>AllowCustomPaging <com:RunBar PagePath="Controls.Samples.TDataGrid.Sample6" />
<h2>Extending TDataGrid</h2>
+<p>
+Besides traditional class inheritance, extensibility of TDataGrid is mainly through developing new datagrid column components. For example, one may want to display an image column. He may use <tt>TTemplateColumn</tt> to accomplish this task. A better solution is to develop an image column component so that the work can be reused easily in other projects.
+</p>
+<p>
+All datagrid column components must inherit from <tt>TDataGridColumn</tt>. The main method that needs to be overridden is <tt>initializeCell()</tt> which creates content for cells in the corresponding column. Since each cell is also in an item (row) and the item can have different types (such as <tt>Header</tt>, <tt>AltneratingItem</tt>, etc.), different content may be created according to the item type. For the image column example, one may want to create a <tt>TImage</tt> control within cells residing in items of <tt>Item</tt> and <tt>AlterantingItem</tt> types.
+</p>
+<com:TTextHighlighter CssClass="source">
+class ImageColumn extends TDataGridColumn {
+ ...
+ public function initializeCell($cell,$columnIndex,$itemType) {
+ parent::initializeCell($cell,$columnIndex,$itemType);
+ if($itemType==='Item' || $itemType==='AlternatingItem') {
+ $image=new TImage;
+ // ... customization of the image
+ $cell->Controls[]=$image;
+ }
+ }
+}
+</com:TTextHighlighter>
+<p>
+In <tt>initializeCell()</tt>, remember to call the parent implementation, as it initializes cells in items of <tt>Header</tt> and <tt>Footer</tt> types.
+</p>
</com:TContent>
\ No newline at end of file |