Adding A Custom Column To The Adminhtml Grid Widget

Recently it was necessary to add a new custom column to the Adminhtml Grid widget, as a new delivery date value had been created but was not appearing in the orders view associated to the customer.

So the form to be modified has been centralised and can be found at: /app/design/adminhtml/default/{theme}/template/widget/grid.phtml

at the top of this form the following was added, based on the requirement of the custom delivery date field that had already been created.

$this->addColumn('delivery_datetime', array(
    'header' => $this->__('Delivery Datetime'),
    'index' => 'delivery_datetime',
    'type' => 'date',
    'width' => '100px',

This was superb and added the column to the end of the grid. However, it was far more useful to apply the column after the store information, so the order of the grid was changed with the following code snippet:

$this->addColumnsOrder('delivery_datetime', 'store_id')

The store_id value was extracted when the following debug code was added into the form, which while a little unsightly, both from a coding and a layout perspective, identified the values involved in the grid:

var_dump ($innerInnerColumn);

This code was placed after

<?php foreach ($this->getColumns() as $_column): ?>


Leave a Reply

Your email address will not be published. Required fields are marked *