1

I have created custom grid in Admin panel to display a question/answers..

For Columns, I am displaying the question id instead of the question text.

And answers are shown in row for each customer.

I want to show a tooltip(question text), when admin hovers on the column (i.e. question id).

Has anyone achieved this before? If so, could you please point me in right direction?

Thank in advance

  • Do you mean hover on columns or hover on rows? – oleksii.svarychevskyi Jan 29 '14 at 13:46
  • Hover on columns – Raks Jan 29 '14 at 13:49
  • Tooltip should appear when you hover above column header or all column space? – oleksii.svarychevskyi Jan 29 '14 at 13:51
  • It shows "asc" for all columns.. Can I change it to display question text? – Raks Jan 29 '14 at 14:03
1

It is not easy to do in correct way. Magento has no native functionality to change colums title. But you can override

Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract::renderHeader()

For example in grid class you can

    $column = $this->addColumn(
        'id',
        array(
            'header' => Mage::helper('yourmodule')
                    ->__('ID'),
            'width'  => '50px',
            'index'  => 'id'
        )
    );
   $column->setTitle('Title');

And rewrite block Mage_Adminhtml_Block_Widget_Grid_Column with your block and method renderHeader() like this

public function renderHeader()
{
    if (false !== $this->getColumn()->getGrid()->getSortable() && false !== $this->getColumn()->getSortable()) {
        $className = 'not-sort';
        $dir = strtolower($this->getColumn()->getDir());
        $nDir= ($dir=='asc') ? 'desc' : 'asc';
        if ($this->getColumn()->getDir()) {
            $className = 'sort-arrow-' . $dir;
        }
        $out = '<a href="#" name="' . $this->getColumn()->getId() . '" title="' . $this->getColumn()->getTitle()
               . '" class="' . $className . '"><span class="sort-title">'
               . $this->getColumn()->getHeader().'</span></a>';
    } else {
        $out = $this->getColumn()->getHeader();
    }
    return $out;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.