From d76123127139a7cb013a0e4c17a63eb8aab57e3e Mon Sep 17 00:00:00 2001
From: "Christophe.Boulain" <>
Date: Tue, 29 Sep 2009 08:33:46 +0000
Subject: Added TActiveDataGrid and TActiveRepeater from LCS
---
.../protected/pages/ActiveControls/Home.page | 71 +++++---
.../Samples/TActiveDataGrid/Sample1.page | 17 ++
.../Samples/TActiveDataGrid/Sample1.php | 41 +++++
.../Samples/TActiveDataGrid/Sample2.page | 65 +++++++
.../Samples/TActiveDataGrid/Sample2.php | 91 ++++++++++
.../Samples/TActiveDataGrid/Sample3.page | 83 +++++++++
.../Samples/TActiveDataGrid/Sample3.php | 190 +++++++++++++++++++++
.../Samples/TActiveDataGrid/Sample4.page | 55 ++++++
.../Samples/TActiveDataGrid/Sample4.php | 21 +++
.../Samples/TActiveDataGrid/Sample5.page | 62 +++++++
.../Samples/TActiveDataGrid/Sample5.php | 73 ++++++++
.../Samples/TActiveDataGrid/Sample6.page | 26 +++
.../Samples/TActiveDataGrid/Sample6.php | 56 ++++++
.../Samples/TActiveRepeater/RegionDisplay.php | 28 +++
.../Samples/TActiveRepeater/RegionDisplay.tpl | 34 ++++
.../Samples/TActiveRepeater/Sample1.page | 47 +++++
.../Samples/TActiveRepeater/Sample1.php | 41 +++++
.../Samples/TActiveRepeater/Sample2.page | 58 +++++++
.../Samples/TActiveRepeater/Sample2.php | 79 +++++++++
.../Samples/TActiveRepeater/Sample3.page | 104 +++++++++++
.../Samples/TActiveRepeater/Sample3.php | 84 +++++++++
.../Samples/TActiveRepeater/Sample4.page | 27 +++
.../Samples/TActiveRepeater/Sample4.php | 43 +++++
.../Samples/TActiveRepeater/Sample5.page | 18 ++
.../Samples/TActiveRepeater/Sample5.php | 52 ++++++
25 files changed, 1439 insertions(+), 27 deletions(-)
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page
create mode 100644 demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.php
(limited to 'demos/quickstart/protected/pages')
diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page
index 49855980..4897226c 100644
--- a/demos/quickstart/protected/pages/ActiveControls/Home.page
+++ b/demos/quickstart/protected/pages/ActiveControls/Home.page
@@ -70,12 +70,12 @@ TActiveButton control. See also the later part of the TActivePager
- generates UI that allows users to interactively specify which page of
- data to be displayed in a data-bound control.
-
+
+
+
+TActiveDataGrid Sample 1
+Using Automatically Generated Columns
+
+
+
+$Id: Sample1.page 1650 2007-01-24 06:55:32Z wei $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php
new file mode 100644
index 00000000..ec78006b
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample1.php
@@ -0,0 +1,41 @@
+'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
+ array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
+ array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
+ array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
+ array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
+ array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
+ array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
+ array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
+ array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
+ array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
+ array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
+ array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
+ array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
+ array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
+ array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
+ array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
+ array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
+ array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
+ array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page
new file mode 100644
index 00000000..851fd157
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.page
@@ -0,0 +1,65 @@
+
+
+TActiveDataGrid Sample 2
+Using Manually Specified Columns
+
+
+
+
+
+
+
+
+ Rating
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+$Id: Sample2.page 1650 2007-01-24 06:55:32Z wei $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php
new file mode 100644
index 00000000..486d9d51
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample2.php
@@ -0,0 +1,91 @@
+'0596007124',
+ 'title'=>'Head First Design Patterns',
+ 'publisher'=>'O\'Reilly Media, Inc.',
+ 'price'=>29.67,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201633612',
+ 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.04,
+ 'instock'=>true,
+ 'rating'=>5,
+ ),
+ array(
+ 'ISBN'=>'0321247140',
+ 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>37.49,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201485672',
+ 'title'=>'Refactoring: Improving the Design of Existing Code',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.14,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ array(
+ 'ISBN'=>'0321213351',
+ 'title'=>'Refactoring to Patterns',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>38.49,
+ 'instock'=>true,
+ 'rating'=>2,
+ ),
+ array(
+ 'ISBN'=>'0735619670',
+ 'title'=>'Code Complete',
+ 'publisher'=>'Microsoft Press',
+ 'price'=>32.99,
+ 'instock'=>false,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0321278658',
+ 'title'=>'Extreme Programming Explained : Embrace Change',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>34.99,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+ }
+
+ public function toggleColumnVisibility($sender,$param)
+ {
+ foreach($this->DataGrid->Columns as $index=>$column)
+ $column->Visible=$sender->Items[$index]->Selected;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function redraw($sender,$param)
+ {
+ $this->DataGrid->render($param->NewWriter);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page
new file mode 100644
index 00000000..94aa95fe
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.page
@@ -0,0 +1,83 @@
+
+
+TActiveDataGrid Sample 3
+Interacting with TActiveDataGrid
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+$Id: Sample3.page 1650 2007-01-24 06:55:32Z wei $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php
new file mode 100644
index 00000000..bb18f36b
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample3.php
@@ -0,0 +1,190 @@
+_data===null)
+ $this->loadData();
+ return $this->_data;
+ }
+
+ protected function loadData()
+ {
+ // We use viewstate keep track of data.
+ // In real applications, data should come from database using an SQL SELECT statement.
+ // In the following tabular data, field 'ISBN' is the primary key.
+ // All update and delete operations should come with an 'id' value in order to go through.
+ if(($this->_data=$this->getViewState('Data',null))===null)
+ {
+ $this->_data=array(
+ array(
+ 'ISBN'=>'0596007124',
+ 'title'=>'Head First Design Patterns',
+ 'publisher'=>'O\'Reilly Media, Inc.',
+ 'price'=>29.67,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201633612',
+ 'title'=>'Design Patterns: Elements of Reusable Object-Oriented Software',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.04,
+ 'instock'=>true,
+ 'rating'=>5,
+ ),
+ array(
+ 'ISBN'=>'0321247140',
+ 'title'=>'Design Patterns Explained : A New Perspective on Object-Oriented Design',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>37.49,
+ 'instock'=>true,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0201485672',
+ 'title'=>'Refactoring: Improving the Design of Existing Code',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>47.14,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ array(
+ 'ISBN'=>'0321213351',
+ 'title'=>'Refactoring to Patterns',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>38.49,
+ 'instock'=>true,
+ 'rating'=>2,
+ ),
+ array(
+ 'ISBN'=>'0735619670',
+ 'title'=>'Code Complete',
+ 'publisher'=>'Microsoft Press',
+ 'price'=>32.99,
+ 'instock'=>false,
+ 'rating'=>4,
+ ),
+ array(
+ 'ISBN'=>'0321278658 ',
+ 'title'=>'Extreme Programming Explained : Embrace Change',
+ 'publisher'=>'Addison-Wesley Professional',
+ 'price'=>34.99,
+ 'instock'=>true,
+ 'rating'=>3,
+ ),
+ );
+ $this->saveData();
+ }
+ }
+
+ protected function saveData()
+ {
+ $this->setViewState('Data',$this->_data);
+ }
+
+ protected function updateBook($isbn,$title,$publisher,$price,$instock,$rating)
+ {
+ // In real applications, data should be saved to database using an SQL UPDATE statement
+ if($this->_data===null)
+ $this->loadData();
+ $updateRow=null;
+ foreach($this->_data as $index=>$row)
+ if($row['ISBN']===$isbn)
+ $updateRow=&$this->_data[$index];
+ if($updateRow!==null)
+ {
+ $updateRow['title']=$title;
+ $updateRow['publisher']=$publisher;
+ $updateRow['price']=TPropertyValue::ensureFloat(ltrim($price,'$'));
+ $updateRow['instock']=TPropertyValue::ensureBoolean($instock);
+ $updateRow['rating']=TPropertyValue::ensureInteger($rating);
+ $this->saveData();
+ }
+ }
+
+ protected function deleteBook($isbn)
+ {
+ // In real applications, data should be saved to database using an SQL DELETE statement
+ if($this->_data===null)
+ $this->loadData();
+ $deleteIndex=-1;
+ foreach($this->_data as $index=>$row)
+ if($row['ISBN']===$isbn)
+ $deleteIndex=$index;
+ if($deleteIndex>=0)
+ {
+ unset($this->_data[$deleteIndex]);
+ $this->saveData();
+ }
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+ }
+
+ public function itemCreated($sender,$param)
+ {
+ $item=$param->Item;
+ if($item->ItemType==='EditItem')
+ {
+ // set column width of textboxes
+ $item->BookTitleColumn->TextBox->Columns=40;
+ $item->PriceColumn->TextBox->Columns=5;
+ }
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem' || $item->ItemType==='EditItem')
+ {
+ // add an aleart dialog to delete buttons
+ $item->DeleteColumn->Button->Attributes->onclick='if(!confirm(\'Are you sure?\')) return false;';
+ }
+ }
+
+ public function editItem($sender,$param)
+ {
+ $this->DataGrid->EditItemIndex=$param->Item->ItemIndex;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function saveItem($sender,$param)
+ {
+ $item=$param->Item;
+ $this->updateBook(
+ $this->DataGrid->DataKeys[$item->ItemIndex], // ISBN
+ $item->BookTitleColumn->TextBox->Text, // title
+ $item->PublisherColumn->TextBox->Text, // publisher
+ $item->PriceColumn->TextBox->Text, // price
+ $item->InStockColumn->CheckBox->Checked, // instock
+ $item->RatingColumn->DropDownList->SelectedValue // rating
+ );
+ $this->DataGrid->EditItemIndex=-1;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function cancelItem($sender,$param)
+ {
+ $this->DataGrid->EditItemIndex=-1;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function deleteItem($sender,$param)
+ {
+ $this->deleteBook($this->DataGrid->DataKeys[$param->Item->ItemIndex]);
+ $this->DataGrid->EditItemIndex=-1;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page
new file mode 100644
index 00000000..76a2bb86
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.page
@@ -0,0 +1,55 @@
+
+
+TActiveDataGrid Sample 4
+Sorting with TActiveDataGrid
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+$Id: Sample4.page 1650 2007-01-24 06:55:32Z wei $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php
new file mode 100644
index 00000000..80a9c8bc
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample4.php
@@ -0,0 +1,21 @@
+ $b["'.$key.'"]) ? 1 : -1;}');
+ usort($data,$compare) ;
+ return $data ;
+ }
+
+ public function sorTActiveDataGrid($sender,$param)
+ {
+ $this->DataGrid->DataSource=$this->sortData($this->Data,$param->SortExpression);
+ $this->DataGrid->dataBind();
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page
new file mode 100644
index 00000000..a912c0d3
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.page
@@ -0,0 +1,62 @@
+
+
+TActiveDataGrid Sample 5
+Paging
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Next Page Text:
+
+Prev Page Text:
+
+
+
+
+
+
+Page Button Count:
+
+
+
+
+
+
+
+
+
+
+
+$Id: Sample5.page 1650 2007-01-24 06:55:32Z wei $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php
new file mode 100644
index 00000000..37347c7b
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample5.php
@@ -0,0 +1,73 @@
+DataGrid->CurrentPageIndex=$param->NewPageIndex;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function pagerCreated($sender,$param)
+ {
+ $param->Pager->Controls->insertAt(0,'Page: ');
+ }
+
+ public function changePagerPosition($sender,$param)
+ {
+ $top=$sender->Items[0]->Selected;
+ $bottom=$sender->Items[1]->Selected;
+ if($top && $bottom)
+ $position='TopAndBottom';
+ else if($top)
+ $position='Top';
+ else if($bottom)
+ $position='Bottom';
+ else
+ $position='';
+ if($position==='')
+ $this->DataGrid->PagerStyle->Visible=false;
+ else
+ {
+ $this->DataGrid->PagerStyle->Position=$position;
+ $this->DataGrid->PagerStyle->Visible=true;
+ }
+ }
+
+ public function useNumericPager($sender,$param)
+ {
+ $this->DataGrid->PagerStyle->Mode='Numeric';
+ $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
+ $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
+ $this->DataGrid->PagerStyle->PageButtonCount=$this->PageButtonCount->Text;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function useNextPrevPager($sender,$param)
+ {
+ $this->DataGrid->PagerStyle->Mode='NextPrev';
+ $this->DataGrid->PagerStyle->NextPageText=$this->NextPageText->Text;
+ $this->DataGrid->PagerStyle->PrevPageText=$this->PrevPageText->Text;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function changePageSize($sender,$param)
+ {
+ $this->DataGrid->PageSize=TPropertyValue::ensureInteger($this->PageSize->Text);
+ $this->DataGrid->CurrentPageIndex=0;
+ $this->DataGrid->DataSource=$this->Data;
+ $this->DataGrid->dataBind();
+ }
+
+ public function redrawDG ($sender, $param)
+ {
+ $this->DataGrid->render($param->newWriter);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page
new file mode 100644
index 00000000..dd3fcdf8
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.page
@@ -0,0 +1,26 @@
+
+
+TActiveDataGrid Sample 6
+Custom Paging
+
+
+
+
+
+$Id: Sample6.page 1650 2007-01-24 06:55:32Z wei $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php
new file mode 100644
index 00000000..7b217e24
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveDataGrid/Sample6.php
@@ -0,0 +1,56 @@
+getData();
+ $page=array();
+ for($i=0;$i<$rows;++$i)
+ {
+ if($offset+$i<$this->getRowCount())
+ $page[$i]=$data[$offset+$i];
+ }
+ return $page;
+ }
+
+ /**
+ * Returns total number of data rows.
+ * In real DB applications, this may be replaced by an SQL select
+ * query with count().
+ * @return integer total number of data rows
+ */
+ protected function getRowCount()
+ {
+ return 19;
+ }
+
+ public function onLoad($param)
+ {
+ if(!$this->IsPostBack)
+ {
+ $this->DataGrid->DataSource=$this->getDataRows(0,$this->DataGrid->PageSize);
+ $this->DataGrid->dataBind();
+ }
+ }
+
+ public function changePage($sender,$param)
+ {
+ $this->DataGrid->CurrentPageIndex=$param->NewPageIndex;
+ $offset=$param->NewPageIndex*$this->DataGrid->PageSize;
+ $this->DataGrid->DataSource=$this->getDataRows($offset,$this->DataGrid->PageSize);
+ $this->DataGrid->dataBind();
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php
new file mode 100644
index 00000000..40d1841e
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.php
@@ -0,0 +1,28 @@
+Data is available which
+ * refers to the data row associated with the parent repeater item.
+ */
+ public function onDataBinding($param)
+ {
+ parent::onDataBinding($param);
+ $this->Repeater->DataSource=$this->Data['detail'];
+ $this->Repeater->dataBind();
+ }
+
+ public function itemCreated($sender,$param)
+ {
+ static $itemIndex=0;
+ $item=$param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ $item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF";
+ $itemIndex++;
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl
new file mode 100644
index 00000000..0ab9b164
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/RegionDisplay.tpl
@@ -0,0 +1,34 @@
+
+
+TActiveRepeater Sample 1
+
+
+
+
+
+
+ ID |
+ Name |
+ Quantity |
+ Price |
+ Imported |
+
+
+
+
+
+<%#$this->Data['id']%> |
+<%#$this->Data['name']%> |
+<%#$this->Data['quantity']%> |
+<%#$this->Data['price']%> |
+<%#$this->Data['imported']?'Yes':'No'%> |
+
+
+
+
+
+<%#$this->Data['id']%> |
+<%#$this->Data['name']%> |
+<%#$this->Data['quantity']%> |
+<%#$this->Data['price']%> |
+<%#$this->Data['imported']?'Yes':'No'%> |
+
+
+
+
+
+Computer Parts Inventory |
+
+
+
+
+
+
+$Id: Sample1.page 1688 2007-02-09 22:48:31Z xue $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php
new file mode 100644
index 00000000..905a3b8d
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample1.php
@@ -0,0 +1,41 @@
+'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
+ array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
+ array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
+ array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
+ array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
+ array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
+ array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
+ array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
+ array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
+ array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
+ array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
+ array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
+ array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
+ array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
+ array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
+ array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
+ array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
+ array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
+ array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->Repeater->DataSource=$this->getData();
+ $this->Repeater->dataBind();
+ }
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page
new file mode 100644
index 00000000..bdb6ec2f
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.page
@@ -0,0 +1,58 @@
+
+
+TActiveRepeater Sample 2
+
+
+
+
+
+
+
+
+
+
+ <%#$this->Data %>
+
+
+
+
+
+
+
+
+
+
+
+ <%#$this->Data['name'] %>
+
+
+ <%#$this->Data['age'] %>
+
+
+ <%#$this->Data['position'] %>
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+$Id: Sample2.page 1688 2007-02-09 22:48:31Z xue $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php
new file mode 100644
index 00000000..e84580a2
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample2.php
@@ -0,0 +1,79 @@
+array(
+ array('name'=>'John','age'=>30,'position'=>'Program Manager'),
+ array('name'=>'Edward','age'=>35,'position'=>'Developer'),
+ array('name'=>'Walter','age'=>28,'position'=>'Developer'),
+ ),
+ 'West'=>array(
+ array('name'=>'Cary','age'=>31,'position'=>'Senior Manager'),
+ array('name'=>'Ted','age'=>25,'position'=>'Developer'),
+ array('name'=>'Kevin','age'=>28,'position'=>'Developer'),
+ ),
+ 'East'=>array(
+ array('name'=>'Shawn','age'=>30,'position'=>'Sales Manager'),
+ array('name'=>'Larry','age'=>28,'position'=>'Document Writer'),
+ ),
+ 'South'=>array(
+ array('name'=>'King','age'=>30,'position'=>'Program Manager'),
+ array('name'=>'Carter','age'=>22,'position'=>'Developer'),
+ ),
+ );
+ return $data[$region];
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->Repeater->DataSource=$this->getMasterData();
+ $this->Repeater->dataBind();
+ }
+ }
+
+ public function dataBindRepeater2($sender,$param)
+ {
+ $item=$param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
+ $item->Repeater2->DataSource=$this->getDetailData($item->DataItem);
+ $item->Repeater2->dataBind();
+ }
+ }
+
+ public function repeaterItemCreated($sender,$param)
+ {
+ static $itemIndex=0;
+ $item=$param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
+ $item->Cell->BackColor=$itemIndex%2 ? "#6078BF" : "#809FFF";
+ $item->Cell->ForeColor='white';
+ $itemIndex++;
+ }
+ }
+
+ public function repeater2ItemCreated($sender,$param)
+ {
+ static $itemIndex=0;
+ $item=$param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
+ $item->Row->BackColor=$itemIndex%2 ? "#BFCFFF" : "#E6ECFF";
+ $itemIndex++;
+ }
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page
new file mode 100644
index 00000000..1ea4e9dc
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.page
@@ -0,0 +1,104 @@
+
+
+TActiveRepeater Sample 3
+
+
+The following example allows users to modify the existing tabular data using a TActiveRepeater. Two validators are used in the repeater to ensure the validity of user inputs. One is to ensure product names are not empty, the other ensures product prices are valid numeric format. After clicking on the save button, the input data is displayed in a table at the bottom of the page.
+
+
+
+
+ Name |
+ Category |
+ Price |
+ Imported |
+
+
+
+
+
+ Data['name']%>
+ AutoPostBack="true"
+ OnTextChanged="Page.saveInput"
+ OnCallback="Page.renderRepeater2"/>
+ |
+
+
+ |
+
+ Data['price']%>
+ AutoPostBack="true"
+ OnTextChanged="Page.saveInput"
+ OnCallback="Page.renderRepeater2"/>
+ |
+
+ Data['imported']%>
+ AutoPostBack="true"
+ OnCheckedChanged="Page.saveInput"
+ OnCallback="Page.renderRepeater2"/>
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ID |
+ Name |
+ Category |
+ Price |
+ Imported |
+
+
+
+
+
+<%#$this->Data['id']%> |
+<%#$this->Data['name']%> |
+<%#$this->Data['category']%> |
+<%#$this->Data['price']%> |
+<%#$this->Data['imported']?'Yes':'No'%> |
+
+
+
+
+
+Computer Parts Inventory |
+
+
+
+
+
+
+
+
+$Id: Sample3.page 1688 2007-02-09 22:48:31Z xue $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php
new file mode 100644
index 00000000..4cb5fafd
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample3.php
@@ -0,0 +1,84 @@
+'ITN001','name'=>'Motherboard','category'=>'CAT004','price'=>100.00,'imported'=>true),
+ array('id'=>'ITN002','name'=>'CPU','category'=>'CAT004','price'=>150.00,'imported'=>true),
+ array('id'=>'ITN003','name'=>'Harddrive','category'=>'CAT003','price'=>80.00,'imported'=>true),
+ array('id'=>'ITN006','name'=>'Keyboard','category'=>'CAT002','price'=>20.00,'imported'=>false),
+ array('id'=>'ITN008','name'=>'CDRW drive','category'=>'CAT003','price'=>40.00,'imported'=>true),
+ array('id'=>'ITN009','name'=>'Cooling fan','category'=>'CAT001','price'=>10.00,'imported'=>false),
+ array('id'=>'ITN012','name'=>'Floppy drive','category'=>'CAT003','price'=>12.00,'imported'=>false),
+ array('id'=>'ITN013','name'=>'CD drive','category'=>'CAT003','price'=>20.00,'imported'=>true),
+ array('id'=>'ITN014','name'=>'DVD drive','category'=>'CAT003','price'=>80.00,'imported'=>true),
+ array('id'=>'ITN015','name'=>'Mouse pad','category'=>'CAT001','price'=>5.00,'imported'=>false),
+ );
+ }
+
+ protected function getCategories()
+ {
+ return array(
+ array('id'=>'CAT001','name'=>'Accessories'),
+ array('id'=>'CAT002','name'=>'Input Devices'),
+ array('id'=>'CAT003','name'=>'Drives'),
+ array('id'=>'CAT004','name'=>'Barebone'),
+ );
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack && ! $this->IsCallBack)
+ {
+ $this->Repeater->DataSource=$this->Products;
+ $this->Repeater->dataBind();
+ }
+ }
+
+ public function repeaterDataBound($sender,$param)
+ {
+ $item=$param->Item;
+ if($item->ItemType==='Item' || $item->ItemType==='AlternatingItem')
+ {
+ $item->ProductCategory->DataSource=$this->Categories;
+ $item->ProductCategory->DataTextField='name';
+ $item->ProductCategory->DataValueField='id';
+ $item->ProductCategory->dataBind();
+ $item->ProductCategory->SelectedValue=$item->DataItem['category'];
+ }
+ }
+
+ public function saveInput($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ $index=0;
+ $products=$this->Products;
+ $data=array();
+ foreach($this->Repeater->Items as $item)
+ {
+ $item=array(
+ 'id'=>$products[$index]['id'],
+ 'name'=>$item->ProductName->Text,
+ 'category'=>$item->ProductCategory->SelectedItem->Text,
+ 'price'=>TPropertyValue::ensureFloat($item->ProductPrice->Text),
+ 'imported'=>$item->ProductImported->Checked,
+ );
+ $data[]=$item;
+ $index++;
+ }
+ $this->Repeater2->DataSource=$data;
+ $this->Repeater2->dataBind();
+ }
+ }
+
+ public function renderRepeater2 ($sender, $param)
+ {
+ $this->Repeater2->render($param->getNewWriter());
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page
new file mode 100644
index 00000000..b4bb622c
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.page
@@ -0,0 +1,27 @@
+
+
+TActiveRepeater Sample 4
+
+Please enter the URL of your favorite websites in the following:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+$Id: Sample4.page 1688 2007-02-09 22:48:31Z xue $
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php
new file mode 100644
index 00000000..0b42436e
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample4.php
@@ -0,0 +1,43 @@
+IsPostBack)
+ {
+ // use a dummy data source to create 3 repeater items
+ $this->Repeater->DataSource=new TDummyDataSource(3);
+ $this->Repeater->dataBind();
+ }
+ }
+
+ public function itemCreated($sender,$param)
+ {
+ // $param->Item refers to the newly created repeater item
+ $param->Item->Style="width:300px; margin:10px; margin-left:0px";
+ }
+
+ public function buttonClicked($sender,$param)
+ {
+ $links=array();
+ foreach($this->Repeater->Items as $textBox)
+ {
+ if($textBox->Text!=='')
+ $links[]=$textBox->Text;
+ }
+ $this->Repeater2->DataSource=$links;
+ $this->Repeater2->dataBind();
+ }
+
+ public function redrawRepeater2($sender,$param)
+ {
+ $this->lblResult->setDisplay(TDisplayStyle::Dynamic);
+ $this->Repeater2->render($param->NewWriter);
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page
new file mode 100644
index 00000000..ee9992d9
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveRepeater/Sample5.page
@@ -0,0 +1,18 @@
+