setValues

sets values into the inputs of a form/toolbar/property sheet control

void setValues(object values, [boolean update] );

Parameters

valuesobjecta hash of "property:value" pairs
updatebooleanoptional, if true, updates the form with new values while existing values remain. false by default

Example

webix.ui({
    view:"property",
    id:"sheet",
    elements:[
        { type:"text", id:"field_a" },
        { type:"text", id:"field_b" },
    ]
});
 
function set_form(){
    $$("sheet").setValues({
       field_a: "London", 
       field_b: "New York"
    });
};

Related samples

Details

The method allows setting several values at a time. Pass the IDs of the necessary elements and their values into the function.

Complex Data

In the complex data mode the object with values can feature sub items of any complexity level. In this case elements names are concatenated from all the data names in the chain:

webix.ui({
    view:"property",
    id:"sheet"
    complexData:true,
    elements:[
        { type:"text", id:"layout.width" },
        { type:"text", id:"layout.height" }
    ]
});
 
$$("sets").setValues({
    layout:{
        width:250,
        height:480
    }
});

Complex data mode is enabled with the help of a same-name parameter in the form/toolbar/property sheet configuration.

Updating values

The second parameter helps manipulate values separately. By default, it is set to false.

Take that we want to set a new value for a field_b input from the property sheet described above.

$$("sheet").setValues({ field_b:"Paris" });

In this case the value for the field_a is lost.

To avoid this, set the update parameter to true. The property sheet will be updated with a new value for field_b input while field_a value remains unchanged.

$$("sheet").setValues({ field_b:"Paris" }, true);
See also
Back to top