在 UI 复选框小部件中绑定 NOT 查询表达式?

Binding a NOT query expression in UI checkbox widget?

我必须根据 3 个值过滤结果 - "done"、"pending" 和第三个选项,它会在 @[= 中找到任何不是 "done" 或 "pending" 的内容26=]

是否可以绑定第 3 个复选框按钮以显示任何未“完成”或 "pending" 的值——例如 !(Type = :done 或 Type = :pending)

这是我到目前为止的屏幕截图,出现的错误是:

Cannot complete binding from nullItemName to @datasources.Data.items.length 
( Type = :done or Type = :pending). Unexpected error on binding initial 
sync write : Null item name cannot be set to null. in
FiltersDialog.Content.Dropdown1

Screenshot of drop-down menu with NOT query

我想出了一个可能的解决方案,因为这是未经测试的,但不能保证它会起作用。

需要对您当前的绑定进行以下编辑:

1.) 完全删除名称绑定并将 nullItemName 设置回 'No Selection'。
2.) 将选项绑定更改为 (@models.Data.fields.Type.possibleValues).concat('Not done or pending').
3.) 完全删除值绑定。
4.) 在您的下拉 onValueChange 事件中输入以下内容:

if(newValue !== null) {
  if (newValue === 'Not done or pending') {
    widget.datasource.query.filters.Type._notIn = ['done','pending'];
  } else {
    widget.datasource.query.filters.Type._equals = newValue;
  }
}

如果您选择向类型字段添加其他可能的值,并为了更安全 UI 提供更好的未来兼容性,我建议进行以下编辑和添加:

确保您的“清除”按钮包括:

widget.datasource.query.clearFilters();
widget.root.descendants.Dropdown1.value = null;

修改您的选项绑定到 (@models.Data.fields.Type.possibleValues).concat(‘Not ‘ + (@models.Data.fields.Type.possibleValues).join(‘ or ‘))

修改onValueChange事件为:

if(newValue !== null) {
  if(newValue === widget.options[widget.options.length - 1]) {
    widget.datasource.query.filters.Type._notIn = widget.datasource.model.fields.Type.possibleValues;
  } else {
    widget.datasource.query.filters.Type._equals = newValue;
  }
}

可能需要对新代码进行微调,因为我只是凭记忆输入。现在我面前真的没有 App Maker。