Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
class Home extends TPage
4
{
5
 
6
	/**
7
	 * function to render callback and refresh the TActivePanel content
8
	 */
9
 
10
	public function RenderCallback($sender, $param)
11
	{
12
		$this->TActivePanel->render($param->NewWriter);
13
	}
14
 
15
	/**
16
	 * Returns total number of data items.
17
	 * In DB-driven applications, this typically requires
18
	 * execution of an SQL statement with COUNT function.
19
	 * Here we simply return a constant number.
20
	 */
21
	protected function getDataItemCount()
22
	{
23
		return 19;
24
	}
25
 
26
	/**
27
	 * Fetches a page of data.
28
	 * In DB-driven applications, this can be achieved by executing
29
	 * an SQL query with LIMIT clause.
30
	 */
31
	protected function getData($offset,$limit)
32
	{
33
		$data=array(
34
			array('id'=>'ITN001','name'=>'Motherboard','quantity'=>1,'price'=>100.00,'imported'=>true),
35
			array('id'=>'ITN002','name'=>'CPU','quantity'=>1,'price'=>150.00,'imported'=>true),
36
			array('id'=>'ITN003','name'=>'Harddrive','quantity'=>2,'price'=>80.00,'imported'=>true),
37
			array('id'=>'ITN004','name'=>'Sound card','quantity'=>1,'price'=>40.00,'imported'=>false),
38
			array('id'=>'ITN005','name'=>'Video card','quantity'=>1,'price'=>150.00,'imported'=>true),
39
			array('id'=>'ITN006','name'=>'Keyboard','quantity'=>1,'price'=>20.00,'imported'=>false),
40
			array('id'=>'ITN007','name'=>'Monitor','quantity'=>2,'price'=>300.00,'imported'=>true),
41
			array('id'=>'ITN008','name'=>'CDRW drive','quantity'=>1,'price'=>40.00,'imported'=>true),
42
			array('id'=>'ITN009','name'=>'Cooling fan','quantity'=>2,'price'=>10.00,'imported'=>false),
43
			array('id'=>'ITN010','name'=>'Video camera','quantity'=>20,'price'=>30.00,'imported'=>true),
44
			array('id'=>'ITN011','name'=>'Card reader','quantity'=>10,'price'=>24.00,'imported'=>true),
45
			array('id'=>'ITN012','name'=>'Floppy drive','quantity'=>50,'price'=>12.00,'imported'=>false),
46
			array('id'=>'ITN013','name'=>'CD drive','quantity'=>25,'price'=>20.00,'imported'=>true),
47
			array('id'=>'ITN014','name'=>'DVD drive','quantity'=>15,'price'=>80.00,'imported'=>true),
48
			array('id'=>'ITN015','name'=>'Mouse pad','quantity'=>50,'price'=>5.00,'imported'=>false),
49
			array('id'=>'ITN016','name'=>'Network cable','quantity'=>40,'price'=>8.00,'imported'=>true),
50
			array('id'=>'ITN017','name'=>'Case','quantity'=>8,'price'=>65.00,'imported'=>false),
51
			array('id'=>'ITN018','name'=>'Surge protector','quantity'=>45,'price'=>15.00,'imported'=>false),
52
			array('id'=>'ITN019','name'=>'Speaker','quantity'=>35,'price'=>65.00,'imported'=>false),
53
		);
54
		return array_slice($data,$offset,$limit);
55
	}
56
 
57
	/**
58
	 * Determines which page of data to be displayed and
59
	 * populates the datalist with the fetched data.
60
	 */
61
	protected function populateData()
62
	{
63
		$offset=$this->DataList->CurrentPageIndex*$this->DataList->PageSize;
64
		$limit=$this->DataList->PageSize;
65
		if($offset+$limit>$this->DataList->VirtualItemCount)
66
			$limit=$this->DataList->VirtualItemCount-$offset;
67
		$data=$this->getData($offset,$limit);
68
		$this->DataList->DataSource=$data;
69
		$this->DataList->dataBind();
70
	}
71
 
72
	public function onLoad($param)
73
	{
74
		parent::onLoad($param);
75
		if(!$this->IsPostBack)
76
		{
77
			$this->DataList->VirtualItemCount=$this->DataItemCount;
78
			$this->populateData();
79
		}
80
	}
81
 
82
	/**
83
	 * Event handler to the OnPageIndexChanged event of pagers.
84
	 */
85
	public function pageChanged($sender,$param)
86
	{
87
		$this->DataList->CurrentPageIndex=$param->NewPageIndex;
88
		$this->populateData();
89
	}
90
}
91
 
92
?>