diff options
Diffstat (limited to 'demos/quickstart/protected/pages/Controls/Samples')
| -rw-r--r-- | demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page | 24 | ||||
| -rw-r--r-- | demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php | 56 | 
2 files changed, 80 insertions, 0 deletions
| diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page new file mode 100644 index 00000000..c8a8c9a2 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.page @@ -0,0 +1,24 @@ +<com:TContent ID="body">
 +
 +<h1>TDataGrid Sample 6</h1>
 +<h2>Custom Paging</h2>
 +
 +<com:TDataGrid
 +	ID="DataGrid"
 +	AllowPaging="true"
 +	AllowCustomPaging="true"
 +	VirtualItemCount="19"
 +	PageSize="5"
 +	PagerStyle.Mode="Numeric"
 +	PagerStyle.HorizontalAlign="Right"
 +	Width="500px"
 +	CellPadding="2"
 +	HeaderStyle.BackColor="black"
 +	HeaderStyle.ForeColor="white"
 +	ItemStyle.BackColor="#BFCFFF"
 +	ItemStyle.Font.Italic="true"
 +	AlternatingItemStyle.BackColor="#E6ECFF"
 +	OnPageIndexChanged="changePage"
 +	/>
 +
 +</com:TContent>
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php new file mode 100644 index 00000000..90e3f7fe --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TDataGrid/Sample6.php @@ -0,0 +1,56 @@ +<?php
 +
 +Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample1');
 +
 +class Sample6 extends Sample1
 +{
 +	/**
 +	 * Returns a subset of data.
 +	 * In MySQL database, this can be replaced by LIMIT clause
 +	 * in an SQL select statement.
 +	 * @param integer the starting index of the row
 +	 * @param integer number of rows to be returned
 +	 * @return array subset of data
 +	 */
 +	protected function getDataRows($offset,$rows)
 +	{
 +		$data=$this->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 | 
