将小部件链接到查询的数据源时遇到麻烦 [英] Had trouble linking widget to a queried datasource

查看:46
本文介绍了将小部件链接到查询的数据源时遇到麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定每个人都已经知道这一点,但是花了我一段时间才弄清楚,所以我想我会分享.

I'm sure everyone already knows this, but it took me a while to figure out so I thought I would share.

基本上,我试图告诉小部件根据模型中条目的当前状态更改颜色.

Basically I was trying tell a widget to change color based on the current status of an entry in my model.

但是我需要将小部件1更改为201房间,将小部件2更改为202房间,等等.

But I needed Widget 1 to change for Room 201, Widget 2 to change for Room 202, etc.

例如:

房间:201,状态:可用=小部件1:绿色 房间:202,状态:已预订=小部件2:红色

Room: 201, Status: Available = Widget 1: Green Room: 202, Status: Booked = Widget 2: Red

我可以让小部件更改颜色(这要感谢 Project List Sample ),但是我很困惑如何将其单独的数据源更改为查询.它们基本上只会显示与数据库/表中当前所选项目相对应的颜色.

I could get the widgets to change color (thanks to borrowing from the code in the Project List Sample), but I was confused how to change their individual datasources to a query. They would basically only show the color corresponding to the currently selected item in the database/table.

所以,这就是我所做的:

So, here is what I did:

进入我的模型,进入数据源下,并添加了一个新的数据源.

Went into my Model, went under Datasources and added a new Datasource.

姓名:Room201

Ex name: Room201

然后在查询"构建器中的我试图缩小的字段"中.

Then in the Query builder I put in the Field I was trying to narrow by.

例如:Room =:查询

ex: Room = :Query

(房间=我的字段,并且我相信:Query"是查询的唯一名称,如果我错了,有人可以纠正我)

(Room = my field, and I believe the ":Query" is the just name of the query, someone can correct me if I'm wrong)

然后,您将在该窗口下方看到一个框,您可以在其中添加绑定.所以这就是我输入查询的地方.

Then you'll see a box below that window where you can add a binding. So THAT is where I put in my query.

例如:@ datasources.Facilities.query.filters.Room._equals = 201

ex: @datasources.Facilities.query.filters.Room._equals = 201

(注意:我必须为每个房间创建一个单独的数据源)

(Note: I had to create a separate Datasource for each room)

然后我转到我的窗口小部件,然后为数据源选择查询的数据源(Room201).

Then I went to my widget and chose the queried datasource (Room201) for the datasource.

因此,小部件1 =数据源Room201,小部件2 =数据源Room202,等等

So Widget 1 = the datasource Room201, Widget 2 = the datasource Room202, etc.

完成.

希望能对某人有所帮助!

Hopefully that helps someone!

推荐答案

将问题的作者(Adam Bergeron)解决方案作为实际的堆栈溢出答案发布:

Posting the author's (Adam Bergeron) solution to the question as an actual Stack Overflow answer:

" 所以,这就是我所做的:

" So, here is what I did:

进入我的模型,进入数据源下,并添加了一个新的数据源.

Went into my Model, went under Datasources and added a new Datasource.

姓名:Room201

Ex name: Room201

然后在查询"构建器中的我试图缩小的字段"中.

Then in the Query builder I put in the Field I was trying to narrow by.

例如:Room =:查询

ex: Room = :Query

(房间=我的字段,并且我相信:Query"是查询的唯一名称,如果我错了,有人可以纠正我)

(Room = my field, and I believe the ":Query" is the just name of the query, someone can correct me if I'm wrong)

然后,您将在该窗口下方看到一个框,您可以在其中添加绑定.所以这就是我要输入查询的地方.

Then you'll see a box below that window where you can add a binding. So THAT is where I put in my query.

例如:@ datasources.Facilities.query.filters.Room._equals = 201

ex: @datasources.Facilities.query.filters.Room._equals = 201

(注意:我必须为每个房间创建一个单独的数据源)

(Note: I had to create a separate Datasource for each room)

然后我转到我的窗口小部件,然后为数据源选择查询的数据源(Room201).

Then I went to my widget and chose the queried datasource (Room201) for the datasource.

因此,小部件1 =数据源Room201,小部件2 =数据源Room202,等等.

So Widget 1 = the datasource Room201, Widget 2 = the datasource Room202, etc.

完成.

希望能对某人有所帮助! "

Hopefully that helps someone! "

这篇关于将小部件链接到查询的数据源时遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆