2

I use Webix 2.5.14. There was a problem with a component Richselect. In this form there is a richselect with options.

webix.ui({
view: "form",
id:"addAccessForm",
borderless: true,
elements: [
    {
        view: "richselect",
        id:"rule",
        label: 'Rule',
        value:1,
        options:[
            {id:1,value:"R"},
            {id:2,value:"W"},
            {id:3,value:"RW"},
            {id:4,value:"RW+"}
        ]
    },
    ....
]
});

I click on the button and opens a form for editing, and I need to select an element in the richselect area, for example with id = 3. How to do it? setValue () adds a new one (element), but doesn't select what i need.

4

2 回答 2

0

You need to use

$$("rule").setValue(3); // 3 - id of record

It is a bit counterintuitive, but you need to use the "id" of record in the setValue command, not the value.

于 2015-10-20T16:22:50.640 回答
0

See my example:

webix.ui({
view: "form",
id:"addAccessForm",
borderless: true,
elements: [
    {
        view: "richselect",
        id:"rule",
        label: 'Rule',
        value:1,
        options:[
            {id:1,value:"R"},
            {id:2,value:"W"},
            {id:3,value:"RW"},
            {id:4,value:"RW+"}
        ]
    },
    { view:"button", value: "Select Value", click:function(){
      $$("rule").setValue(2);
    }}

]
});

or if you prefer http://webix.com/snippet/5df7e1b1

于 2015-10-29T14:14:07.220 回答