Ext JS 6 colorfield UX - show color instead of value

爱⌒轻易说出口 提交于 2019-12-11 07:29:29

问题


Trying to use the colorfield UX and the default is that after you choose a color it shows the hex value of that color in the picker. My users don't know what that means... how can I instead set the background-color of the picker to the chosen color (without the text hex value)? Thanks!

fiddle


回答1:


You cannot easily remove the value from the input field, because that would cause issues with the picker and form submission. You can, however, adjust both text color and background color:

listeners: {
    afterrender: function(cmp) {
        if(cmp.inputEl && cmp.inputEl.dom) {
            cmp.inputEl.dom.style.backgroundColor = "#" + cmp.getValue();
            cmp.inputEl.dom.style.color = "#" + cmp.getValue();
        }
    },
    change: function(cmp, nV) {
        if(cmp.inputEl && cmp.inputEl.dom) {
            cmp.inputEl.dom.style.backgroundColor = "#" + nV;
            cmp.inputEl.dom.style.color = "#" + nV;
        }
    }
}

This means the hex value is still visible if someone selects the text in the colorfield:



来源:https://stackoverflow.com/questions/50380596/ext-js-6-colorfield-ux-show-color-instead-of-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!