Jump to content

Hide ID column in helperList


acuarelweb

Recommended Posts

Hi there.

Im trying to make a custom orders list module controller, and would like to know if is possible to hide the id column while keeping the edit & view buttons (the addRowAction ones...)

 

 

My helperList fields are as follows:


		$this->fields_list = array(
			'id_order' => array(
				'title' => $this->l('ID'),
				'align' => 'text-center',
				'class' => 'fixed-width-xs',
				'search' => false,
				'filter_key' => 'a!id_order', // clave da consulta mysql que queremo amosar..
				'orderby' => true, // necesario para indicar que si se pode ordenar	
				'visible'=>false
			),

			'reference' => array(
				'title' => $this->l('Ticket'),
				'align' => 'text-center',
				'class' => 'fixed-width-xs',
				'search' => true,
				'filter_key' => 'a!reference', // clave da consulta mysql wue queremo amosar..
				'orderby' => true // necesario para indicar que si se pode ordenar	
				
			),
			'date_add' => array(
					'title' => $this->l('Fecha'),
					'align' => 'text-right',
					'type' => 'datetime',
					'filter_key' => 'a!date_add',
					'search' => false,
					
					'orderby'=>true
			)			
		);

If i remove the part from the ID, it is not shown in the list, but the edit or view links dont work as it seems the id_order parameter is needed. I don't know how... 

 

Is there any parameter in the field list or any other workaround to accomplish this via php (css is not a solution here :-)

 

Thanks in advance.

 

Regards, Acuarel

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...

I found a simple solution for this using css.
 
1. Create a file in this path: httpdocs/override/controllers/admin/AdminOrdersController.php
 
2. Paste in the following code:

<?php

class AdminOrdersController extends AdminOrdersControllerCore {
   public function __construct() 
   {
    parent::__construct();

    // Adding a class in order to apply css to the id column (display: none;)
    $this->fields_list['id_order']['class'] = 'fixed-width-xs id_order ';

   }

    // Adding a css file
    public function setMedia()
   {
        parent::setMedia(); // CSS files
        $this->addCSS(__PS_BASE_URI__.$this->admin_webpath.'/themes/'.$this->bo_theme.'/css/mystyle.css');
    }
}

  
  

3. create a css file in the following path: httpdocs/[admin]/themes/[current theme]/css/mystyle.css

 

4. paste in the following code:

body.adminorders table.order .id_order { display: none; }

// Hiding the filter of the ID column, assuming the ID column is the second column in the table, otherwise adjust
// the number for the ":nth-child" to match the column number.
body.adminorders table.order tr.filter th:nth-child(2) { display: none; }

THATS IT! 

The ID column should no longer be displayed.

(This works in prestashop 1.6.0.9 and wasn't tested in other versions)

Edited by josh barak (see edit history)
Link to comment
Share on other sites

  • 3 years later...

In the case someone end up here, there is an easy solution for this. Just add hidden:
'class' => 'hidden'

in the field array class, e.g:

'id_order' => array(
                'title' => $this->l('ID'),
                'align' => 'text-center',
                'class' => 'hidden',
                'search' => false,
                'filter_key' => 'a!id_order', // clave da consulta mysql que queremo amosar..
                'orderby' => true, // necesario para indicar que si se pode ordenar    
                'visible'=>false
            ),

Edited by pelleringa (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...