0

I have a custom grid, and I wanna remove the highlighted parts from it: enter image description here

I wanna remove only from my custom grid. What would be the best way?

This is my Grid.php:

public function __construct()
{
    parent::__construct();
    $this->setFilterVisibility(false);
    $this->setId('integrationGrid');
    $this->setDefaultSort('entity_id');
    $this->setDefaultDir('ASC');
    $this->setSaveParametersInSession(true);
    $this->setUseAjax(true);
}

public function _prepareLayout()
{
    $this->unsetChild('reset_filter_button');
    $this->unsetChild('search_button');
}


protected function _prepareCollection()
{
    $collection = Mage::getModel('novapc_allnations/integration')->getCollection();

    $this->setCollection($collection);
    parent::_prepareCollection();
    return $this;
}


protected function _prepareColumns()
{
    $this->addColumn(
        'integrate_option',
        array(
            'header'    => Mage::helper('novapc_allnations')->__('Integrate'),
            'index'     => 'integrate_option',
            'type'      => 'text',
            'filter'    => false,
            'renderer'  => 'Novapc_Allnations_Block_Adminhtml_Integration_Renderer_Syncproducts',
            'sortable'  => false
        )
    );
    $this->addColumn(
        'updated_at',
        array(
            'header'    => Mage::helper('novapc_allnations')->__('Updated at'),
            'index'     => 'updated_at',
            'width'     => '300px',
            'type'      => 'datetime',
            'filter'    => false,
            'renderer'  => 'Novapc_Allnations_Block_Adminhtml_Integration_Renderer_Updatedat',
            'sortable'  => false
        )
    );
    $this->addColumn(
        'first_update',
        array(
            'header'    => Mage::helper('novapc_allnations')->__('First update'),
            'index'     => 'first_update',
            'width'     => '300px',
            'type'      => 'datetime',
            'filter'    => false,
            'renderer'  => 'Novapc_Allnations_Block_Adminhtml_Integration_Renderer_Createdat',
            'sortable'  => false
        )
    );
    return parent::_prepareColumns();
}


/**
 * get the grid url
 *
 * @access public
 * @return string
 * @author .
 */
public function getGridUrl()
{
    return $this->getUrl('*/*/grid', array('_current'=>true));
}


protected function _afterLoadCollection()
{
    $this->getCollection()->walk('afterLoad');
    parent::_afterLoadCollection();
}

protected function _prepareMassaction()
{
    $this->setMassactionIdField('entity_id');
    $this->getMassactionBlock()->setFormFieldName('allnations_integration');

    $this->getMassactionBlock()->addItem(
        'integratecat',
        array(
            'label' => Mage::helper('novapc_allnations')->__('Integrar Categorias'),
            'url'   => $this->getUrl('*/*/massCategory')
        )
    )
        ->addItem(
            'integrateprod',
            array(
                'label' => Mage::helper('novapc_allnations')->__('Integrar Produtos'),
                'url'   => $this->getUrl('*/*/massIntegrateProduct')
            )
        )
        ->addItem(
            'updatestock',
            array(
                'label' => Mage::helper('novapc_allnations')->__('Atualizar Estoque'),
                'url'   => $this->getUrl('*/*/massUpdateStock')
            )
        )->setUseSelectAll(false);

    return $this;
}
1

To remove Pager use this code at grid.php:

public function __construct()
{
    parent::__construct();
    $this->setSaveParametersInSession(true);
    $this->setPagerVisibility(false);
    $this->setUseAjax(true);
}

For remove checkboxes, use below code at grid.php (same file):

protected function _prepareMassaction()
{
     return $this;
}

To only remove checkboxes.

At grid.php

add this line above _construct() function

protected $_massactionBlockName = 'Namespace_Module_Block_Adminhtml_Widget_Grid_Massaction';

Aftert that create file at Namespace/Module/Block/Adminhtml/Widget/Grid/Massaction.php

Massaction.php

<?php
class Namespace_Module_Block_Adminhtml_Widget_Grid_Massaction extends Mage_Adminhtml_Block_Widget_Grid_Massaction
{
    public function __construct()
    {
        parent::__construct();
        $this->setTemplate('module/widget/grid/massaction.phtml');
    }

    /**
     * Retrieve select all functionality flag check
     *
     * @return boolean
     */
    public function getUseSelectSection()
    {
        return $this->_getData('use_select_all_section') === null || $this->_getData('use_select_all_section');
    }

    /**
     * Retrieve select all functionality flag check
     *
     * @param boolean $flag
     * @return Mage_Adminhtml_Block_Widget_Grid_Massaction_Abstract
     */
    public function setUseSelectSection()
    {
        $this->setData('use_select_all_section', (bool) $flag);
        return $this;       
    }
}

And at end massaction.phtml

<?php
/**
* 
*/
?>
<div id="<?php echo $this->getHtmlId() ?>">
<table cellspacing="0" cellpadding="0" class="massaction">
<tr>
    <?php $this->getUseSelectSection(): ?>
        <td><?php if ($this->getUseSelectAll()):?>
            <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectAll()"><?php echo $this->__('Select All') ?></a>
            <span class="separator">|</span>
            <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectAll()"><?php echo $this->__('Unselect All') ?></a>
            <span class="separator">|</span>
            <?php endif; ?>
            <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectVisible()"><?php echo $this->__('Select Visible') ?></a>
            <span class="separator">|</span>
            <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectVisible()"><?php echo $this->__('Unselect Visible') ?></a>
            <span class="separator">|</span>
            <strong id="<?php echo $this->getHtmlId() ?>-count">0</strong> <?php echo $this->__('items selected') ?>
        </td>
    <?php endif; ?>
    <td>
        <div class="right">
            <div class="entry-edit">
                <?php if ($this->getHideFormElement() !== true):?>
                <form action="" id="<?php echo $this->getHtmlId() ?>-form" method="post">
                <?php endif ?>
                    <?php echo $this->getBlockHtml('formkey')?>
                    <fieldset>
                        <span class="field-row">
                            <label><?php echo $this->__('Actions') ?></label>
                            <select id="<?php echo $this->getHtmlId() ?>-select" class="required-entry select absolute-advice local-validation">
                                <option value=""></option>
                                <?php foreach($this->getItems() as $_item): ?>
                                    <option value="<?php echo $_item->getId() ?>"<?php echo ($_item->getSelected() ? ' selected="selected"' : '')?>><?php echo $_item->getLabel() ?></option>
                                <?php endforeach; ?>
                            </select>
                        </span>
                        <span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-hiddens"></span>
                        <span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-additional"></span>
                        <span class="field-row">
                            <?php echo $this->getApplyButtonHtml() ?>
                        </span>
                    </fieldset>
                <?php if ($this->getHideFormElement() !== true):?>
                </form>
                <?php endif ?>
            </div>

            <div class="no-display">
            <?php foreach($this->getItems() as $_item): ?>
                <div id="<?php echo $this->getHtmlId() ?>-item-<?php echo $_item->getId() ?>-block">
                    <?php echo $_item->getAdditionalActionBlockHtml() ?>
                </div>
            <?php endforeach; ?>
            </div>
        </div>
    </td>
</tr>
</table>
<?php if(!$this->getParentBlock()->canDisplayContainer()): ?>
<script type="text/javascript">
    <?php echo $this->getJsObjectName() ?>.setGridIds('<?php echo $this->getGridIdsJson() ?>');
</script>
<?php endif; ?>
</div>

You are done!!!..

  • Thank you! The pager visibility part worked fine. But I don't wanna remove my checkboxes, just the "select visible" and "unselect visible" part. Do you think thats possible? – Stordon Sep 18 '17 at 12:38
  • Please check my updated asnwer. – Padhiyar Gaurang Sep 19 '17 at 6:15
0

Go to app\design\adminhtml\default\default\template\widget\grid.phtml

line no 59 to 96

<td class="pager" style="display:none;">
            <?php echo $this->__('Page') ?>

            <?php $_curPage  = $this->getCollection()->getCurPage() ?>
            <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
            <?php if($_curPage>1): ?>
                <a href="#" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Previous page')) ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Previous page')) ?>" class="arrow"/></a>
            <?php else: ?>
                <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Previous page')) ?>" class="arrow"/>
            <?php endif; ?>

            <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>

            <?php if($_curPage < $_lastPage): ?>
                <a href="#" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Next page')) ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Next page')) ?>" class="arrow"/></a>
            <?php else: ?>
                <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Go to Next page')) ?>" class="arrow"/>
            <?php endif; ?>

            <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
            <span class="separator">|</span>
            <?php echo $this->__('View') ?>
            <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
                <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
                <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
                <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
                <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
                <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
            </select>
            <?php echo $this->__('per page') ?><span class="separator">|</span>
            <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
            <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
            <?php if($this->getRssLists()): ?>
                <?php foreach ($this->getRssLists() as $_rss): ?>
                <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
                <?php endforeach ?>
            <?php endif; ?>
        </td>

And Go to app\design\adminhtml\default\default\template\widget\grid\massaction.phtml

line no 36 to 40

<a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectVisible()"><?php echo $this->__('Select Visible') ?></a>
        <span class="separator">|</span>
        <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectVisible()"><?php echo $this->__('Unselect Visible') ?></a>
        <span class="separator">|</span>

Remove those code.

showing like this enter image description here

  • you want to remove only Select Visible & Unselect Visible right ? – Ramesh S Sep 15 '17 at 12:23
  • I wanna remove all highlighted parts of the screenshot. Also, wouldn't that remove it from all my grids? – Stordon Sep 15 '17 at 12:25
  • Now see my answer – Ramesh S Sep 15 '17 at 12:29
  • Didn't work properly. It removed both, but it printed the code that called it in the screen. Also, it removed from ALL grids, and I wanna remove just from my custom one. But thanks – Stordon Sep 15 '17 at 12:33
  • see my screen-short for me it's working, can you pls show your output – Ramesh S Sep 15 '17 at 12:35

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.