1111111111111


เว็บใหม่ที่ผมขอใช้ฟรีครับ ภาวนาอยู่ว่าวันดีคืนดีข้อมูลคงไม่หายเหมือนเว็บอื่น

วันจันทร์ที่ 14 มีนาคม พ.ศ. 2554

CButtonColumn หรือ ปุ่มที่เราเห็นกันตาม Grid view ครับ

CButtonColumn หรือ ปุ่มที่เราเห็นกันตาม Grid view



เช่น Delete view ครับ เรามาดูการตกแต่งปุ่มเบื้องต้นกันเถอะ
จาก


'buttonID' => array(
'label'=>'...', // ข้อความที่จะให้ปรากฏบนปุ่ม
'url'=>'...', // ลิ้ง Url
'imageUrl'=>'...', // ภาพที่ต้องการแสดง
'options'=>array(...), // HTML options สำหรับปุ่ม
'click'=>'...', // เมื่อกดจะให้ทำอะไร
'visible'=>'...', // กำหนดการเข้าถึงปุ่ม เช่นเฉพาะผู้ดูแลระบบเท่านั้น
)


แบบที่ 1.



.......
.......
array
(
'class'=>'CButtonColumn',
'template'=>'{email} {down} {delete}',
'buttons'=>array
(
'email' => array // แสดงตำแหน่ง {email}
(
'label'=>'ส่ง Email',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/email.png',
'url'=>'Yii::app()->createUrl("users/email", array("id"=>$data->id))',
),
'down' => array // แสดงตำแหน่ง {down}
(
'label'=>'[-]',
'url'=>'"#"',
'visible'=>'$data->score > 0',
'click'=>'function(){alert("ท่านต้องการให้เลื่อนลงหรือเปล่า");}',
),
'delete'=>'$this->grid->controller->createReturnableUrl("delete",array("id"=>$data->id))',
),
),
.......
.......


แบบที่ 2.



array(
'class'=>'CButtonColumn',
'viewButtonUrl'=>'$this->grid->controller->createReturnableUrl("view",array("id"=>$data->id))',
'updateButtonUrl'=>'$this->grid->controller->createReturnableUrl("update",array("id"=>$data->id))',
'deleteButtonUrl'=>'$this->grid->controller->createReturnableUrl("delete",array("id"=>$data->id))',
'deleteConfirmation'=>Yii::t('ui','Are you sure to delete this item?'),
),


อ้างอิง http://www.yiiframework.com/wiki/106/using-cbuttoncolumn-to-customize-buttons-in-cgridview/



0 ความคิดเห็น: