⚠ In case you've missed it we are migrating to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠

How do I make a custom-column sortable

custom column sortable

  • Please log in to reply
3 replies to this topic

#1 Shibu Menon

Shibu Menon


  • Members
  • Pip
  • 2 posts

Posted 04 June 2015 - 09:50 AM


In my controller function, I am adding a custom column called 'PC-MB', which doesnot exist in the database. The value is dynamically generated using other values in the row. Which works fine.

My question is - how do I make this column sortable. By default, it is not sortable.


        $crud = new grocery_CRUD();
        $crud->set_subject('Highway Data');
        $crud->columns('name',  'last_update', 'PC-MB');
        $crud->callback_column('PC-MB',array($this, '_totalpc_callback') );

        $gcrud_output = $crud->render();


#2 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts

Posted 04 June 2015 - 10:47 AM

HI! Which theme you use? For example, i use datatables theme and sort by custom column easy enough, cause all records in view.

#3 Shibu Menon

Shibu Menon


  • Members
  • Pip
  • 2 posts

Posted 04 June 2015 - 11:59 AM

Thanks Paul. Yes, changing the theme to datatables enabled sorting

#4 saitechnobrains



  • Members
  • Pip
  • 1 posts

Posted 27 October 2018 - 07:14 PM

Hi Paul, I am facing same issue with bootstrap-v4 theme. 

My code:

$output = $this->grocery_crud
->set_relation('state_id', $this->db->dbprefix . 'states', '{state_name}')
->display_as('state_id','State name')
->field_type('user_type', 'hidden', 2)
->field_type('status','true_false', array(1 => 'Active', 2 => 'Inactive'))
->callback_after_insert(array($this, '_callback_insert_bank_details'))
->add_action('Bank Details', '', 'admin/customer_bank_details','el el-plus')
->add_action('Barcode Redeemation', '', 'admin/barcode_redeemation','el el-plus')
->add_action('Point Redeemation', '', 'admin/point_redeemation','el el-plus')

Also tagged with one or more of these keywords: custom column, sortable

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users