Yii Framework Forum: Filter Cgridview By Atributes - Yii Framework Forum

Jump to content

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

Filter Cgridview By Atributes filter cgridview by atributes Rate Topic: -----

#1 User is offline   han2 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 12-November 12

Posted 21 January 2014 - 11:38 AM

para master yii.please help me

saya punya halaman mhs.halaman tersebut menampilkan tabel menggunakan cgridview (seperti pada gambar).alurnya adalah:

- ketika user klik "Mhs-1" atau "Mhs-2" (yg memiliki notrack 23) maka akan dilempar ke url /naskah/tracking/23..halaman itu akan menampilkan semua data dalam cgridview yang memiliki notrack=23

- ketika user klik "Mhs-3" atau "Mhs-7" (yg memiliki notrack 24) maka akan dilempar ke url /naskah/tracking/24..halaman itu akan menampilkan semua data dalam cgridview yang memiliki notrack=24

dst...

ini coding view halaman mhs:
...
array(
          'header'=>'No Urut',
          'name'=>'aksi',
          'type'=>'html',
          'value'=>'CHtml::link(CHtml::encode($data->no_urut), array("/naskah/tracking/$data->notrack/"))',
                ),
...



di controller halaman tracking:
public function actionTracking()
        {       
                $dataProvider=new CActiveDataProvider('Naskah');
                
                $model=new Naskah('search');
                $model->unsetAttributes();
                //$notrack='notrack';
                $model=Naskah::model()->find('notrack=:notrack',array(':notrack'=>$notrack));
                
                $this->render('tracking',array(
                        'dataProvider'=>$dataProvider,
                        'model'=>$model,
                ));
        }


muncul PHP Notice "Undefined variable: notrack"...sepertinya saya kurang mendeklarasikan $notrack.tapi saya bingung meletakkannya.mohon bantuan gan.maap masih belajar, butuh bimbingan :unsure:

Attached File(s)


0

#2 User is offline   han2 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 12-November 12

Posted 22 January 2014 - 10:57 PM

nothing response :-[
0

#3 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 25 January 2014 - 01:50 AM

Ane belom tes, tapi apa agan udah coba rubah kode link-nya jadi:

'value'=>'CHtml::link($data->no_urut, array("/naskah/tracking", "notrack"=>$data->notrack))',


Untuk actionTracking:

public function actionTracking($notrack)
{       
   $model=new Naskah('search');
   $model->unsetAttributes();
   $model->notrack = $notrack;

   $this->render('tracking',array(
       'model'=>$model,
   ));
}


Jangan lupa juga untuk CGridView di view tracking properti dataProvider-nya diset ke:

'dataProvider'=>$model->search(),


Kalo mo pake fungsi search tambahan bisa modifikasi actionTracking ato method search() di model yang berkaitan.
Fipick - Find and pick recommendations
0

#4 User is offline   han2 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 12-November 12

Posted 26 January 2014 - 08:52 AM

View Postrei, on 25 January 2014 - 01:50 AM, said:

Ane belom tes, tapi apa agan udah coba rubah kode link-nya jadi:

'value'=>'CHtml::link($data->no_urut, array("/naskah/tracking", "notrack"=>$data->notrack))',


Untuk actionTracking:

public function actionTracking($notrack)
{       
   $model=new Naskah('search');
   $model->unsetAttributes();
   $model->notrack = $notrack;

   $this->render('tracking',array(
       'model'=>$model,
   ));
}


Jangan lupa juga untuk CGridView di view tracking properti dataProvider-nya diset ke:

'dataProvider'=>$model->search(),


Kalo mo pake fungsi search tambahan bisa modifikasi actionTracking ato method search() di model yang berkaitan.



berhasil gan.solved..waah terimakasih banyak agan rei yang baik hati dan tidak sombong ::)
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