Hello, I would like to use CGridView and CButtonColumn, the buttons should be different for each row conditioned by the data in the row.
So I could have in the first row "Show Update Delete" in the second only "Show" and so on..
Is this possible?
thanks
Page 1 of 1
CButtonColumn different for rows in CGridView
#2
Posted 17 February 2010 - 03:05 PM
Maybe by attaching a behaviour to CDataColumn you could change the buttons template for each row
#4
Posted 19 February 2010 - 11:00 AM
Hello,
thanks for the extension. It helped me to that I was looking for. Hide the update and edit buttons of all rows.
By the way, which is the function of the property visible from CButtonColumn class? Because for me it don't work or I don't know how to use it.
thanks for the extension. It helped me to that I was looking for. Hide the update and edit buttons of all rows.
By the way, which is the function of the property visible from CButtonColumn class? Because for me it don't work or I don't know how to use it.
#5
Posted 19 February 2010 - 05:12 PM
luis diego, on 19 February 2010 - 11:00 AM, said:
Hello,
thanks for the extension. It helped me to that I was looking for. Hide the update and edit buttons of all rows.
By the way, which is the function of the property visible from CButtonColumn class? Because for me it don't work or I don't know how to use it.
thanks for the extension. It helped me to that I was looking for. Hide the update and edit buttons of all rows.
By the way, which is the function of the property visible from CButtonColumn class? Because for me it don't work or I don't know how to use it.
Note that this extension is better suited for the need to have different buttons in different rows... if you want to omit the update button in all rows than it is faster to just set the template property - http://www.yiiframew...template-detail
the visible property is for the custom buttons - http://www.yiiframew...#buttons-detail
Find more about me.... btw. Do you know your WAN IP?
#6
Posted 04 March 2013 - 04:07 AM
I resolved this problem like below:
In this example visibility of delete button depends on result of function CzyTypJestDowiazany().
CGridViewVidget :
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'typy-grid',
'dataProvider'=>$DataProvTU,
'columns'=>array('nazwa',
array('class'=>'CButtonColumn',
'htmlOptions'=>array('style'=>'float:left;'),
'template'=>'{update} {delete}',
'buttons'=>array(
'deleteButtonVisible'=>'User::canDelete($data->id)',
'delete'=>array('url'=>'CController::createUrl("/typyUzytkownikow/delete",array("id"=>$data->primaryKey))',
'visible'=>'CzyTypJestDowiazany($data->id)',
),
),
),
),
));
And now function CzyTypJestDowiazany. You can put it in Controler or in some other file included in index.php.
function CzyTypJestDowiazany($id_typu){
// Put Your code here ...
// whatever you want
// and return false or true depend of result of your code.
if ($RESULT) {return true;}
else {return false;}
}
In this example visibility of delete button depends on result of function CzyTypJestDowiazany().
CGridViewVidget :
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'typy-grid',
'dataProvider'=>$DataProvTU,
'columns'=>array('nazwa',
array('class'=>'CButtonColumn',
'htmlOptions'=>array('style'=>'float:left;'),
'template'=>'{update} {delete}',
'buttons'=>array(
'deleteButtonVisible'=>'User::canDelete($data->id)',
'delete'=>array('url'=>'CController::createUrl("/typyUzytkownikow/delete",array("id"=>$data->primaryKey))',
'visible'=>'CzyTypJestDowiazany($data->id)',
),
),
),
),
));
And now function CzyTypJestDowiazany. You can put it in Controler or in some other file included in index.php.
function CzyTypJestDowiazany($id_typu){
// Put Your code here ...
// whatever you want
// and return false or true depend of result of your code.
if ($RESULT) {return true;}
else {return false;}
}
Share this topic:
Page 1 of 1

Help













