问题标签 [computed-field]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
173 浏览

nhibernate - NHibernate 条件计算域(Hibernate 也可以提供帮助)

我需要在 NHibernate 中创建计算字段,但在这些字段中我必须使用条件表达式。MySQL 示例:

计算字段存储在数据库中,当程序需要该字段时,程序从数据库中获取它,使用它来创建投影,最后,NHibernate 继续执行完整查询。

如何使用 NHibernate 创建包含函数的任何计算字段,而不是为每种方言(Microsoft SQL、Postgresql 或 MySQL)手动创建字段?

0 投票
1 回答
430 浏览

drupal-7 - 字段集合中的 Drupal 7 计算字段

我有一个包含 2 个日期(时间戳)的字段集合,并且想计算日期之间的差异。但我无法让它工作..有什么帮助吗?

0 投票
1 回答
1531 浏览

php - 如何使用 Fivestar 计算用户在其所有节点上的平均评分?

在我的网站上,用户可以在评论中通过名为Stars的 Fivestar 字段对彼此的节点进行评分。我现在想计算用户的总体平均得分。这意味着,我想显示用户所有节点的平均分数。

例如。假设用户创建了 2 个节点:Node 1Node 2。有人评价他的内容:

  • 节点 1得分:4/5、5/5、3/5
  • 节点 2得分:4/5、4/5

那么总体平均值将是 (4+5+3+4+4)/5=4。

优选地,该结果也应显示为星号。

我怎样才能做到这一点?


编辑:使用Computed Field模块似乎是解决这个问题的一般想法。它对我来说看起来不错,我认为最好将用户的平均分数存储在用户字段中,以使其易于访问。(使用视图也可以。)我计划在他们的个人资料页面上显示平均分数,但也许我将来也会在网站的其他地方使用它。

你能帮我看看我应该使用的代码吗?

0 投票
1 回答
1579 浏览

string - 仅在 Powerbuilder 表达式中将部分文本加粗

是否可以在计算字段或文本对象中仅将字符串的特定部分设为粗体。

0 投票
0 回答
44 浏览

java - 如何在Java中序列化方法的输出

我的类包含一个属性“状态”,它的值从 0 到 5。当我序列化对象以将其发布到 webapi 时,我还需要发送一个布尔标志。标志的值可以通过状态值计算(见下面的代码)。

如何序列化 computeFlag() 方法的输出?在Java中可能吗?该标志仅在与 webapi 通信时使用,在其他任何地方都不使用。

0 投票
2 回答
956 浏览

visual-studio-lightswitch - Computed Property as Summary in Lightswitch

I'm creating a Lightswitch project where I have a table of users. The table has FirstName and LastName columns, but when selecting users in other controls I want to display "Firstname LastName".

I've created a computed "FullName" field which concatenates the two fields, but when I selected this field as the summary property, controls listing users still show the first real string property found.

I'm guessing this has something to do with the FullName field not being a real field. Is there a way to make the FullName field a real field, which updates automatically when FirstName or LastName changes?

0 投票
2 回答
935 浏览

xpages - Forcing Computed Fields on a Document to Recalculate using SSJS

Is there a way to force a documents computed fields to recalculate from within an Xpage, without saving the document?

I have a subform on a Notes database with many computed fields, these contain some complex calculations involving time range calculations. The database is used as both a web and client application. For the custom control containing the fields I don't want to have to recreate all the calculations, so have a computed text value bound to the computed form on the document.

On the subform as you tab through entering the information the computed fields are recalculated. On the custom control I have a refresh button which saves the datasource and does a partial refresh of the data entry section, but this can cause some errors or document save conflicts.

I will recreate the calculations if need be, but I just wondered if there is a slicker way of achieving this before I start that process?

0 投票
1 回答
1557 浏览

object - 淘汰赛 foreach 计算值

我正在尝试向我的 viewModel 对象添加一个计算值。我正在使用 foreach 创建一个行表。我无法绕过这个计算函数。

我正在尝试这样做。

我希望 viewModel objectName 输出看起来像

谢谢。KDK

0 投票
1 回答
1654 浏览

arrays - 为什么我的 Ember MutableArray 不宣布更改?

我有一个在整个代码库中使用的对象,我想扩展它,以便它可以像数组一样工作。我已经尝试使用 Ember 的 MutableArray mixin 并取得了一些成功,但我仍然需要手动宣布对对象的更改(即调用foo.arrayContentWillChangefoo.arrayContentDidChange)。我已经提取了大部分代码,ArrayProxy所以它看起来应该很熟悉。

任何帮助,将不胜感激。谢谢!

问题

我必须像这样宣布我对数组的所有更改:

我想像 Ember 数组一样使用我的对象:

对象的使用方式:

类定义

0 投票
2 回答
1736 浏览

lucene - Sitecore 内容搜索 PredicateBuilder 与 IEnumerable

我在查询 IEnumerable 计算索引字段时遇到问题。我正在使用 Sitecore 7.2 upd2、Lucene、ContentSearch 和 PredicateBuilder。

我正在尝试查询产品部分下提供的产品价格。有一些沉重的逻辑来寻找可用的产品,所以我决定将所有可用的产品价格放在计算字段中。不幸的是,我似乎无法使用 PredicateBuilder 查询价格表。

我的查询如下所示:

索引配置中的字段配置:

这就是我的错误:

有任何想法吗?