Yii Framework Forum: ada yang pernah menggabungkan string di CGridView ? - Yii Framework Forum

Jump to content

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

ada yang pernah menggabungkan string di CGridView ? Rate Topic: -----

#1 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 29 March 2011 - 11:03 PM

dear masta2 forum,

ane punya CGridView, misal ada satu kolom isinya NAME, dan satu kolom lagi namanya ADDRESS (dua duanya terpisah).

Lalu, bisa engga kalau di CGridView itu sendiri ditampilkan dengan menggabungkan 2 Field tadi.

jadi tampilannya NAME/ADDRESS ?

misal :

sebelum : NAME ADDRESS sesudah : NAME/ADDRESS
ANITA JL Kepompongan ANITA/JL Kempompongan

Info : menampilkan datanya dengan CArrayDataProvider

Oya, satu lagi, di CGridView bisa di setting untuk Judul kolom dengan dua baris engga?

Misal :

______________
Jenis Kelamin | --->nama kolom
--------------
L | P | --->nama kolom
--------------
y | | --->isi field
| n | --->isi field


Makasih yah.
0

#2 User is offline   petra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 20-June 10

Posted 30 March 2011 - 12:35 AM

tinggal dikonkat aja khan di columnnya

'columns'=>array(
   array(
       'name' => 'name/address',
       'header' => 'Name/Address',
       'value' => '$data[\'name\'].$data[\'address\']',
   )
)

0

#3 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 30 March 2011 - 01:55 AM

View Postpetra, on 30 March 2011 - 12:35 AM, said:

tinggal dikonkat aja khan di columnnya

'columns'=>array(
   array(
       'name' => 'name/address',
       'header' => 'Name/Address',
       'value' => '$data[\'name\'].$data[\'address\']',
   )
)



waw keren mas... makasih mas. berhasil.. :)

btw, kalau judul kolomnya dua baris bisa ga yah...? misal kolom parrent nya Jenis Kelamin, punya dua kolom di dalamnya, yaitu L dan P.

JENIS KELAMIN

L | P
0

#4 User is offline   Br4m 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 25-October 10

Posted 30 March 2011 - 05:24 AM

View Postcocobi, on 30 March 2011 - 01:55 AM, said:

waw keren mas... makasih mas. berhasil.. :)

btw, kalau judul kolomnya dua baris bisa ga yah...? misal kolom parrent nya Jenis Kelamin, punya dua kolom di dalamnya, yaitu L dan P.

JENIS KELAMIN

L | P


Hello cocobi,

You can try this:
'columns'=>array(
array(
       'name' => 'kelamin',
       'header' => 'JENIS KELAMIN <br/> L | P',
       'filter'=> array(L=>"Laki-laki",P=>"Perempuan"),
       'value' => '@$data->kelamin == L ? "Laki-laki" : "Perempuan"',
     )
   )

0

#5 User is offline   petra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 20-June 10

Posted 30 March 2011 - 07:39 AM

Kalo judul kolom 2 baris itu agak repot sih,
harus ngebikin widget baru yang ngeextend CGridView,
terus override method renderTableHeader

tapi ya cara paling gampang bikin kayak yg di atas aja
'header' => '<div class=\'c1'>Jenis Kelamin</div><div class=\'c2\'>L</div><div class=\'c3\'>P</div>'
'value' => '@$data->kelamin == L ? "<div class=\'l\'>Laki-laki</div><div class=\'p\'></div>" : "<div class=\'l\'></div><div class=\'p\'>Perempuan</div>"',

terus maenan di CSSnya aja
0

#6 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 30 March 2011 - 09:12 PM

makasih untuk responnya, tapi actually itsn't what I mean.

Mungkin ane kurang jelas deskripsinya, gini, ada tiga buah kolom, yang masing masing memiliki nilai.

Nama, Alamat, No Telp. Nah di atas ketiga kolom itu, ada nama Kolom KETERANGAN.

Kolom KETERANGAN tidak perlu / bisa di sort ASC / DESC. Sedangankan ketiga kolom tadi tetep normal(bisa di sort).

Gitu permasalahannya gan..hehe
0

#7 User is offline   petra 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 20-June 10

Posted 31 March 2011 - 06:41 AM

ya itu,,, mau gak mau override CGridView aja :D

biar bisa ntar
'columns'=>array(
	array(
		'keterangan' => array( 
			array(
			   'name' => 'nama',
			),
			array(
			   'name' => 'alamat',
			),
			array(
				'name' => 'no telp',
			),
		),
	)
)

0

#8 User is offline   cocobi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 14-January 11

Posted 31 March 2011 - 09:09 PM

View Postpetra, on 31 March 2011 - 06:41 AM, said:

ya itu,,, mau gak mau override CGridView aja :D

biar bisa ntar
'columns'=>array(
	array(
		'keterangan' => array( 
			array(
			   'name' => 'nama',
			),
			array(
			   'name' => 'alamat',
			),
			array(
				'name' => 'no telp',
			),
		),
	)
)




Hmm... nice inpoh gan, Maybe I 'll trying it letter, if no body's have the fastest sollution for this case.. ;) ____Hatur nuhun____
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