1: <?php
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: class Mage_Adminhtml_Block_Poll_Edit_Tab_Answers_Grid extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('answersGrid');
41: $this->setDefaultSort('answer_id');
42: $this->setDefaultDir('ASC');
43: $this->setUseAjax(true);
44: }
45:
46: protected function _prepareCollection()
47: {
48: $collection = Mage::getModel('poll/poll_answer')
49: ->getResourceCollection()
50: ->addPollFilter($this->getRequest()->getParam('id'));
51: $this->setCollection($collection);
52: return parent::_prepareCollection();
53: }
54:
55: protected function _prepareColumns()
56: {
57: $this->addColumn('answer_id', array(
58: 'header' => Mage::helper('poll')->__('ID'),
59: 'align' =>'right',
60: 'width' => '50px',
61: 'index' => 'answer_id',
62: ));
63:
64: $this->addColumn('answer_title', array(
65: 'header' => Mage::helper('poll')->__('Answer Title'),
66: 'align' =>'left',
67: 'index' => 'answer_title',
68: ));
69:
70: $this->addColumn('votes_count', array(
71: 'header' => Mage::helper('poll')->__('Votes Count'),
72: 'type' => 'number',
73: 'width' => '50px',
74: 'index' => 'votes_count',
75: ));
76:
77: $this->addColumn('actions', array(
78: 'header' => Mage::helper('poll')->__('Actions'),
79: 'align' => 'center',
80: 'type' => 'action',
81: 'width' => '10px',
82: 'filter' => false,
83: 'sortable' => false,
84: 'actions' => array(
85: array(
86: 'caption' => Mage::helper('poll')->__('Delete'),
87: 'onClick' => 'return answers.delete(\'$answer_id\')',
88: 'url' => '#',
89: ),
90: ),
91: ));
92:
93: return parent::_prepareColumns();
94: }
95:
96: public function getRowUrl($row)
97: {
98: return $this->getUrl('*/poll_answer/edit', array('id' => $row->getId()));
99: }
100:
101: public function getGridUrl()
102: {
103: return $this->getUrl('*/poll_answer/grid', array('id' => $this->getRequest()->getParam('id')));
104: }
105:
106: }
107: