Make column as link?
Posted 23 October 2012 - 12:23 PM
I want to change a column to a link?
Is it possible?
Posted 23 October 2012 - 12:46 PM
You can use a callback function.
http://www.grocerycr...callback_column
http://www.grocerycrud.com/documentation
Posted 30 October 2012 - 08:48 AM
could anyone help me??
Posted 30 October 2012 - 09:00 AM
Posted 30 October 2012 - 09:26 AM
i want to display add_action button when a certain condition be true .
but when i make it in call back function it doesn't work
when i make it in the controller the condition implement on the whole records
Posted 30 October 2012 - 09:52 AM
public function webpages()
{
$c = new grocery_CRUD();
$c->set_table('your_table');
// field 'action' is an extra virtual field
$c->columns('field1','field2','field4','[color=#ff0000]action[/color]');
$c->callback_column('action',array($this,'_callback_action'));
$output = $c->render();
$this->_view_output($output);
}
public function _callback_action($value, $row)
{
if($row->count >=1)
return '<a href="your_action/'.$row->id.'">'.$value.'</a>';
else return 'no product';
}
Posted 30 October 2012 - 10:05 AM
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('project');
$crud->columns('name','slang','tlang','numwords','price','type','pvalid','state');
$crud->where("project.state = 2");
$crud->add_action('rate', base_url().'images/good.png', '' ,'ui-icon-plus',array($this,'clientrate'));
i want add_action display on a certain records that match the condithion
but the condition implements on all records(the records with state=2 only displayed)
Posted 30 October 2012 - 10:06 AM
function clientrate($primary_key , $row)
{
// if ($row->state == 2){
// $this->view_record(0,$primary_key);
return site_url('signup/addratting/'.$row->state);
}
Posted 30 October 2012 - 10:39 AM
Do You want to put a rating for the row? or for state?
Posted 30 October 2012 - 10:43 AM
$crud->set_theme('flexigrid');
$crud->set_table('project');
$crud->columns('name','slang','tlang','numwords','price','type','pvalid','state',[b] [color=#ff0000]'rate'[/color][/b]);
$crud->callback_column('action',array($this,'_callback_action'));
public function _callback_action($value, $row)
{
if($row->state = 2 )
return '<a href="your_action/'.$row->id.'">'.$value.'</a>';
else return '';
}
Posted 30 October 2012 - 10:57 AM
Posted 30 October 2012 - 11:06 AM
try it:
$crud->columns('Yor field's .......', [color=#ff0000]'rate'[/color]);
columns 'rate' will be created automatically for the list.
Posted 30 October 2012 - 11:08 AM
Posted 30 October 2012 - 11:17 AM
Posted 30 October 2012 - 11:18 AM
Posted 30 October 2012 - 11:27 AM
$crud = new grocery_CRUD();
$crud->set_theme('flexigrid');
$crud->set_table('project');
$crud->columns('name','slang','tlang','numwords','price','type','pvalid','state', 'rate');
$crud->callback_column('rate',array($this,'_callback_action'));
public function _callback_action($value, $row)
{
if($row->state = 2 )
return '<a href="your_action/'.$row->id.'">'.$value.'</a>';
else return '';
}
Posted 30 October 2012 - 11:28 AM
Posted 30 October 2012 - 11:29 AM
Posted 30 October 2012 - 11:43 AM
$crud->set_table('project');
$crud->columns('name','slang','tlang','numwords','price','type','pvalid','state');
$crud->where("project.state = 2");
$crud->add_action('Show & Download', base_url().'images/show.png', '' ,'ui-icon-plus',array($this,'showaction'));
$crud->add_action('rate', base_url().'images/good.png', '' ,'ui-icon-plus',array($this,'clientrate'));
callback function is
function clientrate($primary_key , $row)
{
if ($row->state == 2){
// $this->view_record(0,$primary_key);
return site_url('signup/addratting/'.$row->state);
}
and this is print screen of my grid
http://www.4shared.com/photo/DpIVIAya/untitled.html
i want the rate (yello stare) displaed only in the records with state= finished
Posted 30 October 2012 - 11:47 AM
$crud->callback_add_field('rate',array($this,'amount_field_add_callback'));
$crud->columns('name','slang','tlang','numwords','price','type','pvalid','state','rate');
callback function
public function _callback_action($value, $row)
{
if($row->state == 2 )
return '<a href="signup/addratting/'.$row->id.'">'.$value.'</a>';
else return '';
}
and this is print screen of the result
http://www.4shared.c.../untitled2.html
no data found