From d13ef89849ad340f424084367fc8f16b03266bfd Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 5 Feb 2006 06:52:00 +0000 Subject: Completed DataGrid part II description. --- .../protected/pages/Controls/DataGrid2.page | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'demos/quickstart/protected/pages/Controls') 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 AllowPaging and AllowCustomPaging

Extending TDataGrid

+

+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 TTemplateColumn 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. +

+

+All datagrid column components must inherit from TDataGridColumn. The main method that needs to be overridden is initializeCell() 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 Header, AltneratingItem, etc.), different content may be created according to the item type. For the image column example, one may want to create a TImage control within cells residing in items of Item and AlterantingItem types. +

+ +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; + } + } +} + +

+In initializeCell(), remember to call the parent implementation, as it initializes cells in items of Header and Footer types. +

\ No newline at end of file -- cgit v1.2.3