00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Poll_Edit_Tab_Answers_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('answersGrid');
00041 $this->setDefaultSort('answer_id');
00042 $this->setDefaultDir('ASC');
00043 $this->setUseAjax(true);
00044 }
00045
00046 protected function _prepareCollection()
00047 {
00048 $collection = Mage::getModel('poll/poll_answer')
00049 ->getResourceCollection()
00050 ->addPollFilter($this->getRequest()->getParam('id'));
00051 $this->setCollection($collection);
00052 return parent::_prepareCollection();
00053 }
00054
00055 protected function _prepareColumns()
00056 {
00057 $this->addColumn('answer_id', array(
00058 'header' => Mage::helper('poll')->__('ID'),
00059 'align' =>'right',
00060 'width' => '50px',
00061 'index' => 'answer_id',
00062 ));
00063
00064 $this->addColumn('answer_title', array(
00065 'header' => Mage::helper('poll')->__('Answer Title'),
00066 'align' =>'left',
00067 'index' => 'answer_title',
00068 ));
00069
00070 $this->addColumn('votes_count', array(
00071 'header' => Mage::helper('poll')->__('Votes Count'),
00072 'type' => 'number',
00073 'width' => '50px',
00074 'index' => 'votes_count',
00075 ));
00076
00077 $this->addColumn('actions', array(
00078 'header' => Mage::helper('poll')->__('Actions'),
00079 'align' => 'center',
00080 'type' => 'action',
00081 'width' => '10px',
00082 'filter' => false,
00083 'sortable' => false,
00084 'actions' => array(
00085 array(
00086 'caption' => Mage::helper('poll')->__('Delete'),
00087 'onClick' => 'return answers.delete(\'$answer_id\')',
00088 'url' => '#',
00089 ),
00090 ),
00091 ));
00092
00093 return parent::_prepareColumns();
00094 }
00095
00096 public function getRowUrl($row)
00097 {
00098 return $this->getUrl('*/poll_answer/edit', array('id' => $row->getId()));
00099 }
00100
00101 public function getGridUrl()
00102 {
00103 return $this->getUrl('*/poll_answer/grid', array('id' => $this->getRequest()->getParam('id')));
00104 }
00105
00106 }