作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的模型中有一些选择字段。这里的例子:
class MyModel(models.Model):
_name = 'my_app.my_model'
example_selection = fields.Selection(
[
('first', 'First'),
('second', 'Second'),
# etc.
],
string='My selection',
)
在某些情况下,我需要隐藏选择(或单选按钮)中的特定选项。我怎样才能正确地做到这一点?
下面的屏幕来自基本日历模块,它可以更多地解释我的问题。
提前致谢。
最佳答案
有点晚了。就我而言,我是这样做的:
odoo.define('my_module.custom_selection', function(require) {
"use strict";
var registry = require('web.field_registry');
var relational_fields = require('web.relational_fields');
var MySelection = relational_fields.FieldRadio.extend({
init: function() {
this._super.apply(this, arguments);
// use to decrement in splice, bc position change when element is removed
let decrement = 0;
// this.values can be undefined or [[], [], []]
// copying the content of original array or []
let value_copies = this.values? [...this.values]: [];
for (let index = 0; index < value_copies.length; index++) {
// 'other' is the value to be removed
if (value_copies[index].includes('other')) {
this.values.splice(index - decrement, 1);
decrement++;
}
}
},
});
registry.add('custom_selection', MySelection);
return MySelection;
});
您可以在这里查看我的存储库:https://github.com/m0r7y/wdgt_hide_option
关于javascript - 奥杜。隐藏字段选择中的一些选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35055645/
所以我在 jQuery 可排序方面遇到了奇怪的问题。我有可排序的 li 元素,排序很好,但是在 IE 中,拖动时图像会消失。我相当确定它们的位置很奇怪,但在任何其他浏览器中似乎都不会发生这种情况,其他
我是一名优秀的程序员,十分优秀!