Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
Prado::using('Application.pages.Controls.Samples.TDataGrid.Sample1');
4
 
5
class Sample6 extends Sample1
6
{
7
	/**
8
	 * Returns a subset of data.
9
	 * In MySQL database, this can be replaced by LIMIT clause
10
	 * in an SQL select statement.
11
	 * @param integer the starting index of the row
12
	 * @param integer number of rows to be returned
13
	 * @return array subset of data
14
	 */
15
	protected function getDataRows($offset,$rows)
16
	{
17
		$data=$this->getData();
18
		$page=array();
19
		for($i=0;$i<$rows;++$i)
20
		{
21
			if($offset+$i<$this->getRowCount())
22
				$page[$i]=$data[$offset+$i];
23
		}
24
		return $page;
25
	}
26
 
27
	/**
28
	 * Returns total number of data rows.
29
	 * In real DB applications, this may be replaced by an SQL select
30
	 * query with count().
31
	 * @return integer total number of data rows
32
	 */
33
	protected function getRowCount()
34
	{
35
		return 19;
36
	}
37
 
38
	public function onLoad($param)
39
	{
40
		if(!$this->IsPostBack)
41
		{
42
			$this->DataGrid->DataSource=$this->getDataRows(0,$this->DataGrid->PageSize);
43
			$this->DataGrid->dataBind();
44
		}
45
	}
46
 
47
	public function changePage($sender,$param)
48
	{
49
		$this->DataGrid->CurrentPageIndex=$param->NewPageIndex;
50
		$offset=$param->NewPageIndex*$this->DataGrid->PageSize;
51
		$this->DataGrid->DataSource=$this->getDataRows($offset,$this->DataGrid->PageSize);
52
		$this->DataGrid->dataBind();
53
	}
54
}
55
 
56
?>