1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: namespace picon;
24:
25: 26: 27: 28: 29: 30: 31: 32:
33: class DataTable extends Panel implements Pageable
34: {
35: private $provider;
36: private $gridView;
37: private $columns;
38: private $head;
39: private $foot;
40:
41: public function __construct($id, DataProvider $provider, $columns, $rowsPerPage = 10)
42: {
43: parent::__construct($id);
44: $this->provider = $provider;
45: $this->columns = $columns;
46: $this->$rowsPerPage = $rowsPerPage;
47:
48: $this->gridView = new DataGridView('row', 'col', 'value', $provider, $columns, $rowsPerPage);
49: $this->add($this->gridView);
50:
51: $this->head = new RepeatingView('head');
52: $this->foot = new RepeatingView('foot');
53: $this->add($this->head);
54: $this->add($this->foot);
55: }
56:
57: protected function onComponentTag(ComponentTag $tag)
58: {
59: parent::onComponentTag($tag);
60: $tag->setName('div');
61: }
62:
63: public function setRowsPerPage($rowsPerPage)
64: {
65: Args::isNumeric($rows, 'rowsPerPage');
66: $this->gridView->setRowsPerPage($rowsPerPage);
67: }
68:
69: public function getRowsPerPage()
70: {
71: return $this->gridView->getRowsPerPage();
72: }
73:
74: public function addTopToolbar(AbstractToolbar $toolbar)
75: {
76: $this->head->add($toolbar);
77: }
78:
79: public function addBottomToolbar(AbstractToolbar $toolbar)
80: {
81: $this->foot->add($toolbar);
82: }
83:
84: public function getPageCount()
85: {
86: return $this->gridView->getPageCount();
87: }
88:
89: public function setCurrentPage($page)
90: {
91: $this->gridView->setCurrentPage($page);
92: }
93:
94: public function getCurrentPage()
95: {
96: return $this->gridView->getCurrentPage();
97: }
98:
99: public function getNextToolbarId()
100: {
101: return $this->head->getNextChildId();
102: }
103:
104: public function getColumns()
105: {
106: return $this->columns;
107: }
108:
109: }
110:
111: ?>
112: