doubianxian6557 2015-09-27 15:26
浏览 55
已采纳

如何获取最近查看过的记录的id来执行一个cgridview,它对yii中的每条记录都是唯一的?

I know this is unusual but I want either a cgridview that is unique to each record or an alternative way of doing the thing that I want...

I have a cgridview which displays a list of patients

enter image description here

when the view button is clicked it would go the view page... My view page has an operation on the sidebar called "Display Patient Records of this Patient" and I wanted it to redirect to another cgridview from another model.

The problem now is the cgridView displays all of the patient records instead of just the record of the patient, the user viewed.

Is there a way to get the id of the recently viewed patient record so I can come up with a new dataProvider for this?

take note that I need the id of the recently viewed patient, not the id of the user logged in so I can't just use

Yii::app()->user->id;

I would appreciate any help or another alternative of achieving this...

  • 写回答

3条回答 默认 最新

  • duankanyi6539 2015-09-27 17:01
    关注

    When the view button is clicked on the Manage Patients grid view, In that view page, I hope you have the new menu item set, something similar to:

    array('label'=>'Display Patient Records', 'url'=>array('/controller/patientRecord','id'=>Yii::app()->request->getParam('id');)),
    

    Here Yii::app()->request->getParam('id'); will return you the id of the patient being viewed controller is your controller name and patientRecord is your action name which will return the grid view of the patient's records.

    In the action patientRecord just render the new grid view passing the patient id value to the view, create a new function in your model, similar to the normal search function you have in a model, just add a condition:

    $criteria->condition = "patient_id='$id' ";
    

    When you call the model->search() in your grid view page, pass the id you have, something like: $model->search($id),

    I hope this gives you an idea. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能