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条)

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应