summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/ActiveControls/Samples
diff options
context:
space:
mode:
Diffstat (limited to 'demos/quickstart/protected/pages/ActiveControls/Samples')
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page103
-rw-r--r--demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php92
2 files changed, 195 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page
new file mode 100644
index 00000000..3153088d
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.page
@@ -0,0 +1,103 @@
+<com:TContent ID="body">
+
+<h1>TActivePager Sample</h1>
+<p>
+The following sample displays three different pagers associated with a single TDataList control. The datalist control is enabled with custom paging, which allows it to read only one page of data each time. This is typical in DB-driven applications.
+</p>
+
+<div>
+Go to page:
+<com:TActivePager ID="Pager"
+ ControlToPaginate="DataList"
+ PageButtonCount="3"
+ Mode="Numeric"
+ OnPageIndexChanged="pageChanged"
+ OnCallBack="RenderCallback"
+ >
+ <prop:ClientSide.OnLoading>
+ Element.show('wait')
+ </prop:ClientSide.OnLoading>
+ <prop:ClientSide.OnComplete>
+ Element.hide('wait')
+ </prop:ClientSide.OnComplete>
+</com:TActivePager>
+<span id="wait" style="display: none;color: red">Please Wait...</span>
+</div>
+<com:TActivePanel id="TActivePanel" ActiveControl.EnableUpdate="true">
+<com:TDataList
+ ID="DataList"
+ AllowPaging="true"
+ AllowCustomPaging="true"
+ PageSize="2"
+ EnableViewState="true"
+ RepeatColumns="2"
+ RepeatDirection="Vertical"
+ ItemStyle.Font.Italic="true"
+ ItemStyle.BackColor="#BFCFFF"
+ HeaderStyle.BackColor="black"
+ HeaderStyle.ForeColor="white"
+ FooterStyle.BackColor="gray"
+ AlternatingItemStyle.BackColor="#E6ECFF">
+
+<prop:HeaderTemplate>
+<div style="font-weight:bold; text-align:center;">Computer Parts</div>
+</prop:HeaderTemplate>
+
+<prop:FooterTemplate>
+<div style="font-weight:bold; text-align:center;">
+Total <%# $this->Parent->PageCount %> pages.
+</div>
+</prop:FooterTemplate>
+
+<prop:ItemTemplate>
+<table border="0" width="300">
+<tr>
+ <th>ID</th><th>Name</th><th>Quantity</th><th>Price</th>
+</tr>
+<tr>
+ <td align="right"><com:TLiteral Text=<%#$this->DataItem['id'] %> /></td>
+ <td align="right"><com:TLiteral Text=<%#$this->DataItem['name'] %> /></td>
+ <td align="right"><com:TLiteral Text=<%#$this->DataItem['quantity'] %> /></td>
+ <td align="right">$<com:TLiteral Text=<%#$this->DataItem['price'] %> /></td>
+</tr>
+</table>
+</prop:ItemTemplate>
+
+</com:TDataList>
+</com:TActivePanel>
+
+<com:TActivePager ID="Pager2"
+ ControlToPaginate="DataList"
+ FirstPageText="9"
+ LastPageText=":"
+ Mode="NextPrev"
+ NextPageText="4"
+ PrevPageText="3"
+ Font.Name="Webdings"
+ OnPageIndexChanged="pageChanged"
+ OnCallBack="RenderCallback"
+>
+<prop:ClientSide.OnLoading>
+ Element.show('wait')
+ </prop:ClientSide.OnLoading>
+ <prop:ClientSide.OnComplete>
+ Element.hide('wait')
+ </prop:ClientSide.OnComplete>
+</com:TActivePager>
+<br/>
+Choose page:
+<com:TActivePager ID="Pager3"
+ ControlToPaginate="DataList"
+ Mode="DropDownList"
+ OnPageIndexChanged="pageChanged"
+ OnCallBack="RenderCallback"
+>
+<prop:ClientSide.OnLoading>
+ Element.show('wait')
+ </prop:ClientSide.OnLoading>
+ <prop:ClientSide.OnComplete>
+ Element.hide('wait')
+ </prop:ClientSide.OnComplete>
+</com:TActivePager>
+<com:TJavascriptLogger/>
+<div class="last-modified">$Id$</div></com:TContent>
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php
new file mode 100644
index 00000000..40a867b5
--- /dev/null
+++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActivePager/Home.php
@@ -0,0 +1,92 @@
+<?php
+
+class Home extends TPage
+{
+
+ /**
+ * function to render callback and refresh the TActivePanel content
+ */
+
+ public function RenderCallback($sender, $param)
+ {
+ $this->TActivePanel->render($param->NewWriter);
+ }
+
+ /**
+ * Returns total number of data items.
+ * In DB-driven applications, this typically requires
+ * execution of an SQL statement with COUNT function.
+ * Here we simply return a constant number.
+ */
+ protected function getDataItemCount()
+ {
+ return 19;
+ }
+
+ /**
+ * Fetches a page of data.
+ * In DB-driven applications, this can be achieved by executing
+ * an SQL query with LIMIT clause.
+ */
+ protected function getData($offset,$limit)
+ {
+ $data=array(
+ array('id'=>'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),
+ );
+ return array_slice($data,$offset,$limit);
+ }
+
+ /**
+ * Determines which page of data to be displayed and
+ * populates the datalist with the fetched data.
+ */
+ protected function populateData()
+ {
+ $offset=$this->DataList->CurrentPageIndex*$this->DataList->PageSize;
+ $limit=$this->DataList->PageSize;
+ if($offset+$limit>$this->DataList->VirtualItemCount)
+ $limit=$this->DataList->VirtualItemCount-$offset;
+ $data=$this->getData($offset,$limit);
+ $this->DataList->DataSource=$data;
+ $this->DataList->dataBind();
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ if(!$this->IsPostBack)
+ {
+ $this->DataList->VirtualItemCount=$this->DataItemCount;
+ $this->populateData();
+ }
+ }
+
+ /**
+ * Event handler to the OnPageIndexChanged event of pagers.
+ */
+ public function pageChanged($sender,$param)
+ {
+ $this->DataList->CurrentPageIndex=$param->NewPageIndex;
+ $this->populateData();
+ }
+}
+
+?> \ No newline at end of file