首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在JointJS中显示基于另一个字段的字段

在JointJS中显示基于另一个字段的字段
EN

Stack Overflow用户
提问于 2016-06-10 15:46:20
回答 1查看 450关注 0票数 0

我有一个检查器,其中包含对象的名称和类型的列表,以及我的自定义数据。假设我想根据类型属性的选择来显示我的自定义数据。我可以用'when‘来做这件事,但只有当它是具有特定路径的简单字段时,比如"attr/type“。因为它在列表中,所以索引会有所不同,所以我不知道如何指定路径来检查是否选择了哪种类型。对这个问题有什么想法吗?

    data: {
                        type : 'list',
                        item: {
                            type: 'object',
                            properties: {
                                'name' : {
                                    type : 'text',
                                    group : 'text',
                                    label : 'Name',
                                    index : 1
                                },
                                type : {
                                    type : 'select',
                                    group : 'text',
                                            label : 'Type',
                                            options: ['Text','Number','Date','Select','Text Area'],
                                    index : 2
                                },
                                required : {
                                    type : 'toggle',
                                    group : 'validation',
                                    label : 'Required',
                                    index : 3
                                },
                                'min-length' : {
                                    type : 'number',
                                    group : 'validation',
                                    min : 0,
                                    label : 'Min Length',
                                    index : 4
                                },
                                'max-length' : {
                                    type : 'number',
                                    group : 'validation',
                                    min : 1,
                                    label : 'Max Length',
                                    index : 5
                                },
                                'min' : {
                                    type : 'number',
                                    group : 'validation',
                                    min : 0,
                                    label : 'Min',
                                    index : 6
                                },
                                'max' : {
                                    type : 'number',
                                    group : 'validation',
                                    min : 1,
                                    label : 'Max',
                                    index : 7
                                },
                                'message' : {
                                    type : 'text',
                                    group : 'validation',
                                    label : 'Error message',
                                    index : 8
                                },
                                'regex' : {
                                    type : 'text',
                                    group : 'validation',
                                    label : 'Regex',
                                    index : 9
                                },
                                'options' : {
                                    type : 'list',
                                    item : {
                                        type:'object',
                                        properties: {
                                            'text' : {
                                                type : 'text',
                                                label : 'Text',
                                                index : 1
                                            },
                                            'value' :{
                                                type : 'text',
                                                label : 'Value',
                                                index : 2
                                            }
                                        }
                                    },
                                    group : 'validation',
                                    label : 'Options',
                                    index : 10
                                }

                            }
                        },
                        group : 'validation',
                        label : 'Input',
                        index : 1
                    }
EN

回答 1

Stack Overflow用户

发布于 2018-11-14 17:05:50

您必须在特定元素的属性中提供..

例如,您需要隐藏message元素based on attr/type选项,您需要编写如下代码。

                        'message' : {
                                type : 'text',
                                group : 'validation',
                                label : 'Error message',
                                when: { ne: { 'data/item/type': "Your Option here!!"} },
                                index : 8
                            },

欢迎提出建议!!谢谢

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37742721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档