Yii Framework Forum: passing variable ke htmlOptions di Cgridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

passing variable ke htmlOptions di Cgridview Rate Topic: -----

#1 User is offline   abud 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 01-February 09

Posted 02 February 2011 - 06:35 PM

hai semua,ada yang tau cara passing variabel ($data) ke htmlOptions?

misalnya pada Cgridview
saya menggunakan class CLinkColumn, kemudian pada htmlOptions saya mem

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'tr-header-upah-kary-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
//'id_bagian',
array(
'name'=>'id_bagian',
'header'=>'Bagian',
'value'=>'$data->bagian->nama'
),
'nomor',
//'tgl',
array(
'name'=>'tgl',
'value'=>'date("j M, Y", strtotime($data->tgl))',

),

array(
'class'=>'CLinkColumn',
'header'=>'Action',
'label'=>'Choose',
//'urlExpression'=> "",
'linkHtmlOptions'=>array(
'onClick'=>"headerValue(-----disini saya ingin memberikan argumen nilai id dari $data------)"
// 'onClick'=>"alert('tes')"

),

),



array(
'class'=>'CButtonColumn',
),
),
)); ?>
thank's
0

#2 User is offline   abud 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 01-February 09

Posted 02 February 2011 - 11:47 PM

View Postabud, on 02 February 2011 - 06:35 PM, said:

hai semua,ada yang tau cara passing variabel ($data) ke htmlOptions?

misalnya pada Cgridview
saya menggunakan class CLinkColumn, kemudian pada htmlOptions saya mem

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'tr-header-upah-kary-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
//'id_bagian',
array(
'name'=>'id_bagian',
'header'=>'Bagian',
'value'=>'$data->bagian->nama'
),
'nomor',
//'tgl',
array(
'name'=>'tgl',
'value'=>'date("j M, Y", strtotime($data->tgl))',

),

array(
'class'=>'CLinkColumn',
'header'=>'Action',
'label'=>'Choose',
//'urlExpression'=> "",
'linkHtmlOptions'=>array(
'onClick'=>"headerValue(-----disini saya ingin memberikan argumen nilai id dari $data------)"
// 'onClick'=>"alert('tes')"

),

),



array(
'class'=>'CButtonColumn',
),
),
)); ?>
thank's


thank's problem is solved :D
0

#3 User is offline   sbasuki 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 14-January 10

Posted 02 February 2011 - 11:56 PM

Aku juga punya masalah yg sama, tp ak akalin di value-nya, jangan di htmloptions

ex. my-code:
    array(
    	'value'=>'CHTML::button(\'Add\', array(\'onClick\'=>"pilih(\'$data->unit_no\')"))',
      'type'=>'raw',
			'htmlOptions'=>array('width'=>'40px'),
   	),

0

#4 User is offline   abud 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 01-February 09

Posted 03 February 2011 - 10:08 AM

View Postsbasuki, on 02 February 2011 - 11:56 PM, said:

Aku juga punya masalah yg sama, tp ak akalin di value-nya, jangan di htmloptions

ex. my-code:
    array(
    	'value'=>'CHTML::button(\'Add\', array(\'onClick\'=>"pilih(\'$data->unit_no\')"))',
      'type'=>'raw',
			'htmlOptions'=>array('width'=>'40px'),
   	),


yup, thank's coding aku just for share(dopet dari searching di forum yii internation)

'linkHtmlOptions'=>array(
//'onClick'=>"headerValue($(this).parents('tr').find('td').eq(1).text();)"
'onClick'=>"
var header_id = $(this).parents('tr').find('td').eq(0).text();
alert(header_id);
headerValue(header_id);
"

),

eq nilai column ke berapa yang mau kita ambil
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users