Skip to content

setting object value to the Select editor - #316

Open
jakubwolny wants to merge 1 commit into
powmedia:masterfrom
jakubwolny:master
Open

setting object value to the Select editor#316
jakubwolny wants to merge 1 commit into
powmedia:masterfrom
jakubwolny:master

Conversation

@jakubwolny

Copy link
Copy Markdown

I find it useful when I retrieve data from server as a related record (not only integer id)

@kjvenky

kjvenky commented Jul 20, 2014

Copy link
Copy Markdown

A similar problem exist with arrayToHtml conversion also. Any suggestions on the edit?

I fixed it changing to

/**

  • Create the HTML

  • @PARAM {Array} Options as a simple array e.g. ['option1', 'option2']

  •                  or as an array of objects e.g. [{val: 543, label: 'Title for object 543'}]
    
  • @return {String} HTML
    */
    _arrayToHtml: function(array) {
    var html = [];
    //Generate HTML
    .each(array, function(option) {
    if (
    .isObject(option)) {
    if (option.group) {
    html.push('');
    html.push(this._getOptionsHtml(option.options))
    html.push('');
    } else {
    var val = (option.val || option.val === 0) ? option.val : '';
    html.push(''+option.label+'');
    }
    }
    else {
    if(this.value && this.value.toLowerCase() === option.toLowerCase()){ // If value exits and is not null
    html.push(''+option+'');
    }else{
    html.push(''+option+'');
    }
    }
    }, this);

    return html.join('');
    }

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants