property view - clear function should be public

It's not so obvious that to clear all property data you need to use setValues().
Also, you need to use editStop() or your data will be cleared only after second click off the button. That's because editor return value after you clear property.

https://snippet.webix.com/arfoqdnf

    setValues:function(data, update){
        if (this._settings.complexData)
            data = webix.CodeParser.collapseNames(data);

        if(!update) this._clear();
        for(var key in data){
            var line = this.getItem(key);
            if (line)
                line.value = data[key];
        }

        this._props_dataset = data;
        this.refresh();
    },
    _clear:function(){
        var lines = this._settings.elements;
        for (var i=0; i<lines.length; i++)
            lines[i].value = "";
    },

should be

    setValues:function(data, update){
        if (this._settings.complexData)
            data = webix.CodeParser.collapseNames(data);

        if(!update) this.clear();
        for(var key in data){
            var line = this.getItem(key);
            if (line)
                line.value = data[key];
        }

        this._props_dataset = data;
        this.refresh();
    },
    clear:function(){
        this.editStop();
        var lines = this._settings.elements;
        for (var i=0; i<lines.length; i++)
            lines[i].value = "";
    },

Comments

  • edited April 19

    Hello,

    Yep, it is sensible to add a public clear() method to the ui.property. It will appear in the next build till the end of this month.

    As to another part of the issue, editing operation is applied when the editor is blurred. That's why if at the same moment you perform actions that may interfere you need to firstly close the editor with one of the possible methods: editStop() or editCancel().

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion