Jump to content


Custom column value not showing in view/read?

Custom column

  • Please log in to reply
1 reply to this topic

#1 Sonelal Singh

Sonelal Singh

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 02 July 2015 - 01:28 PM

HI,

 

I have calculated an age by date of birth(dob) field from my database and I am able to calculate age and display it on list page.

But on view/read page all fields value displaying as expected, except age. Below is my code - 

 

 $crud = new grocery_CRUD();
 $crud->set_theme('datatables');
 $crud->set_table('ci_users');
        
$crud->set_subject('User');
$crud->required_fields('empcode', 'firstname', 'lastname', 'email', 'phone', 'password', 'department', 'role', 'status');
$crud->columns('empcode', 'firstname','lastname','email','phone','department', 'role', 'status', 'designation', 'team','Tenure','supervisor','created_date');
$crud->fields('empcode', 'firstname','lastname','email','phone','department', 'role', 'status', 'designation', 'team','supervisor','Tenure');
                
                
$crud->callback_column('created_date', array($this, 'callback_date'));
                
 
//this field I want to display on my read/view page 
$crud->callback_column('Tenure', array($this, 'callback_calculate_tenure'));
                
        
// Field Setup
$crud->change_field_type('password','password');
 
// Relations
 $crud->set_relation('supervisor','ci_users','{firstname} {lastname}');
$crud->set_relation('department','ci_departments','department');
$crud->set_relation('role','ci_roles','roles');
$crud->set_relation('status','ci_status','status');
$crud->set_relation('designation','ci_designations','designation');
$crud->set_relation('team','ci_teams','team');
$crud->unique_fields('email');
$crud->set_rules('email', 'Email', 'required|valid_email');
 
 
 $output['output'] = $crud->render();
 $output['title'] = "abc";
 $output['userrole'] = $this->session->userdata('role');
 $output['pagehead'] = "User Management";
$output['output'] = $crud->render();

 

So what is wrong with my code,why age is not showing on read page.

Note:- I am using version 1.4.2

 



#2 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts
  • LocationUkraine

Posted 03 July 2015 - 09:29 AM

Hi! Have you read docs on the GC site?
 

"//this field I want to display on my read/view page 
$crud->callback_column('Tenure', array($this, 'callback_calculate_tenure'));"  - this is for list view, for read state you have to use callback_field, where you can find out state - read, insert, edit ... e.t.c.






Also tagged with one or more of these keywords: Custom column

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users