0

I tried

'sortable'  => true,

but it didn't work with a column whose content will be resulted from a renderer

$this->addColumn('wh1', array(
      'header'=> Mage::helper('inventory')->__('Physical Inv.<br>WH1'),
       'index' => 'wh1',
    //  'sortable'  => true,
    // begin: render the sku content
        'renderer' => new Lenmar_Adminhtml_Block_Inventory_Inventory_RendererPhWH1Inventory(),
       'width'     => '10px',
         'type' => 'text',
        'filter'    => false,

    ));

I have other renderer and sort for it is working good it seems that it is something with index values but I don't know how to make it work

this one works even with renderer:

    $this->addColumn('item_type', array(
      'header'    => Mage::helper('catalog')->__('Item Type'),
      'width'     => '100px',
      'index'     => 'item_type',
          'type'=>'options',
          'options' => $this->_getAttributeOptions('item_type'),
     'renderer' => new Lenmar_Adminhtml_Block_Inventory_Inventory_RendererTypeInventory(),

    ));

I know that the sort is based on variable of index value forexample if I use sku it will sort them by sku but i don't know what to use instead of wh1 value? its because item_type is an attribute inside magento attributes but wh1 is only in table of mysql not in magento side

2
  • In this case Magento would use 'wh1' field for sorting. What is format of that field and what data does it store? Have you tried to dump collection query and see how it looks and works? – Wojtek Naruniec Nov 12 '14 at 10:12
  • there are just numbers which will be calculated and will be shown – Nickool Nov 12 '14 at 16:48
0

Negin, as it looks that content of your wh1 column is generated in renderer, built-in sorting based on sortable grid config value won't work.

Try to echo you collection select query somewhere in _prepareCollection() method to see how produced SQL query looks:

echo $this->getCollection()->getSelect()

Try to implement sorting in _afterLoadCollection() method after your data is fetched from database. Please find example in answer for following question:

https://stackoverflow.com/questions/7705007/magento-grid-sorting-on-rendered-column

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.