edit delete option disappearing in module

edited February 2016 in Modules
hi in my custom module for linting i am using following code

function list_items($limit = NULL, $offset = NULL, $col = 'id', $order = 'asc')
{

$this->db->select('name,image,box,sample_image', FALSE);
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}
but by this the edit delete option is disappearing while if i am using

$this->db->select('*', FALSE);

instead of
$this->db->select('name,image,box,sample_image', FALSE);

how should i keep the edit delete option while specifying the fields

Comments

  • edited 12:29PM
    You need to include the "id" field so that the table knows what id to edit
  • edited 12:29PM
    it is already their my table structure is like this
    CREATE TABLE `package_type` (
    `id` int(11) NOT NULL,
    `name` varchar(255) NOT NULL,
    `image` varchar(255) NOT NULL,
    `sample_image` varchar(255) NOT NULL,
    `box` enum('orange','blue','pink') NOT NULL,
    `is_disabled` tinyint(1) NOT NULL DEFAULT '0',
    `is_deleated` tinyint(1) NOT NULL DEFAULT '0',
    `modified_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `post_date` datetime NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

    ALTER TABLE `package_type`
    ADD PRIMARY KEY (`id`);

    ALTER TABLE `package_type`
    MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=0;
  • edited 12:29PM
    ok i got it the issue is resolve by using
    $this->db->select('id,name,image,box,sample_image', FALSE);
  • If using table_headers in Simple Module config you need to add the ID/Primary Key column to show EDIT/DELETE!

    $config['modules']['tests'] = array(
        'module_name'    => 'Test',
        'module_uri'     => 'tests',
        'model_name'     => 'Tests_model',
        'table_headers'  => [
            'id'    => 'ID',  // IMPORTANT to show EDIT|DELETE
            'title' => 'Title',
        ]
    );
    
  • Perfect! "ID" worked for me. Thanks!

Sign In or Register to comment.