1

This is my code:

   $this->addColumn(
       $key,
       array(
           header' => Mage::helper('core')->__($key),
           'index' => $key,
           'filter' => 'adminhtml/widget_grid_column_filter_select',
           'sortable' => true,
       )
   );      

I want to get all of the values from my column and put it in the dropdown options values and to filter them. Is there a way to do that ? At the moment I got an empty dropdown.

[UPDATE]

For instance if my values are 2,3,2,3,4,5,6,7 . I want to have in my dropdown the following values: 2,3,4,5,6,7

[UPDATE 2]

I managed to put the values in the dropdown. See My code:

$this->addColumn(
    $key,
    array(
       'header' => Mage::helper('core')->__($key),
       'index' => $key,
       'filter' => 'adminhtml/widget_grid_column_filter_select',
       'sortable' => true,
       'renderer' => $render,
       'type'      => 'options',
       'options'   => $this->_getOrderType(),
      )
);
public function _getOrderType(){
        $types = new Varien_Object(array(
            "Frontend" => "Frontend",
            "AdminPanel" => "AdminPanel"
        ));
        return $types->getData();
}

But my filter doesn't work. If I filter after smth I got an empty grid. enter image description here

[UPDATE 3]

Update with the render function:

public function render(Varien_Object $row)
    {
        $value = $this->_getValue($row);
        if ($value == ""){
            return "Frontend";
        }else {
            return "AdminPanel";
        }
    }
0

I am not sure where the values come from, but you can use native's php array_unique function on the array of values, so the options would be unique.

| improve this answer | |
  • can you check my post again, i made some updates. thx – Attila Naghi Jul 6 '16 at 12:49
  • I don't completely understand what you are trying to achieve here, sorry. But to answer your update - try adding the custom filter callback as described in here: magento.stackexchange.com/questions/21313/… – Wladyslaw Brodsky Jul 6 '16 at 13:08
  • Can you check my image that I attached. I just want to make a filter after the values from my dropdown. At the moment with my code , doesn;t work and I do not know why . Can you help me ? thx in advance :) – Attila Naghi Jul 6 '16 at 13:14
  • What is your $render variable? Can you update the post with the renderer? – Wladyslaw Brodsky Jul 6 '16 at 13:17
  • Check now I did . If my row is empty show Frontend otherwise show Adminpanel – Attila Naghi Jul 6 '16 at 13:21

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.