如何获取最近查看过的记录的id来执行一个cgridview,这对yii中的每条记录都是唯一的?(How to get the id of recently viewed record to do a

编程入门 行业动态 更新时间:2024-10-26 04:22:53
如何获取最近查看过的记录的id来执行一个cgridview,这对yii中的每条记录都是唯一的?(How to get the id of recently viewed record to do a cgridview which is unique to each record in yii?)

我知道这很不寻常,但我想要一个每个记录独有的cgridview,或者我想做的事情的另一种方式...

我有一个cgridview,显示患者列表

单击视图按钮时,它将进入视图页面...我的视图页面在侧栏上有一个名为“显示该患者的患者记录”的操作,我希望它从另一个模型重定向到另一个cgridview。

现在的问题是cgridView显示所有患者记录,而不仅仅是患者的记录,用户查看。

有没有办法获取最近查看的患者记录的ID,以便我可以为此提出一个新的dataProvider?

请注意,我需要最近查看的患者的ID,而不是登录用户的ID,所以我不能只使用

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

我希望得到任何帮助或另一种方法来实现这一目标......

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

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...

最满意答案

在Manage Patients网格视图上单击视图按钮时,在该视图页面中,我希望您设置新的菜单项,类似于:

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

这里Yii::app()->request->getParam('id'); 将返回您正在查看的患者的ID controller是您的控制器名称, patientRecord是您的操作名称,它将返回患者记录的网格视图。

在patientRecord只需渲染新的网格视图,将患者id值传递给视图,在模型中创建一个新函数,类似于模型中的普通search函数,只需添加一个条件:

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

当您在网格视图页面中调用model->search()时,传递您拥有的id ,例如: $model->search($id),

我希望这会给你一个想法。 :)

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. :)

更多推荐

本文发布于:2023-08-04 18:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1419908.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:这对   每条   是唯一   cgridview   id

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!