-
Notifications
You must be signed in to change notification settings - Fork 2
/
Grid.php
executable file
·134 lines (123 loc) · 3.25 KB
/
Grid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
class Convenient_AdminGrid_Block_Adminhtml_Disk_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
/**
*
* @author Luke Rodgers <lukerodgers90@gmail.com>
*/
public function _construct()
{
parent::_construct();
$this->setId('convenient_grid_disk');
$this->setDefaultSort('id');
$this->setDefaultDir(Varien_Data_Collection::SORT_ORDER_ASC);
$this->setUseAjax(true);
$this->setDefaultLimit(30);
}
/**
* @return string
*
* @author Luke Rodgers <lukerodgers90@gmail.com>
*/
public function getGridUrl()
{
return $this->getUrl('*/*/grid', array('_current'=>true));
}
/**
* @return null|string
*
* @author Luke Rodgers <lukerodgers90@gmail.com>
*/
public function getRowUrl()
{
return null;
}
/**
* @return $this|void
* @throws Exception
*
* @author Luke Rodgers <lukerodgers90@gmail.com>
*/
protected function _prepareColumns()
{
$this->addColumn(
'id',
array(
'header' => $this->__('Id'),
'type' => 'number',
'index' => 'id',
)
);
$this->addColumn(
'code',
array(
'header' => $this->__('Code'),
'type' => 'text',
'index' => 'code',
)
);
$this->addColumn(
'number',
array(
'header' => $this->__('Number'),
'type' => 'number',
'index' => 'number',
)
);
$this->addColumn(
'what',
array(
'header' => $this->__('Text'),
'type' => 'text',
'index' => 'text'
)
);
$this->addColumn(
'datelol',
array(
'header' => $this->__('Date'),
'type' => 'date',
'index' => 'date'
)
);
$this->addColumn(
'datetimelol',
array(
'header' => $this->__('Date Time'),
'type' => 'datetime',
'index' => 'datetime',
'filter_time' => true,
)
);
/**
* Populate the select dropdown
*/
$selectOptions = array();
foreach ($this->getCollection() as $item) {
$selectOptions[$item->getData('select')] = $item->getData('select');
}
asort($selectOptions);
$this->getCollection()->clear();
$this->addColumn(
'select',
array(
'header' => $this->__('Select'),
'type' => 'options',
'index' => 'select',
'options' => $selectOptions
)
);
}
/**
* @return Convenient_AdminGrid_Model_Resource_Collection_Disk|Varien_Data_Collection
*
* @author Luke Rodgers <lukerodgers90@gmail.com>
*/
public function getCollection()
{
if (is_null($this->_collection)) {
$this->_collection = Mage::getResourceSingleton('convenient_admingrid/collection_disk');
}
return $this->_collection;
}
}