How to set EXTJS Combobox label width

家住魔仙堡 提交于 2019-12-12 03:19:10

问题


I am trying to get the label for the combobox to show correctly in the example below. I am trying to get it to work in Sencha Fiddle. The text if too long, is getting truncated.

Ext.application({
    name : 'Fiddle',

    launch : function() {


        // The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
    fields: ['abbr', 'name'],
    data : [
        {"abbr":"AL", "name":"Alabama"},
        {"abbr":"AK", "name":"Alaska"},
        {"abbr":"AZ", "name":"Arizona"}
        //...
    ]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Reaaaaaaaaaaaaaaallllllllly long',
    fieldlabelStyle: 'width:600px',//doesn't do anything
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
});
    }
});

回答1:


Try with labelStyle

Ext.application({
    name : 'Fiddle',

    launch : function() {
        // The data store containing the list of states
        var states = Ext.create('Ext.data.Store', {
            fields: ['abbr', 'name'],
            data : [
                {"abbr":"AL", "name":"Alabama"},
                {"abbr":"AK", "name":"Alaska"},
                {"abbr":"AZ", "name":"Arizona"}
                //...
            ]
        });

        // Create the combo box, attached to the states data store
        Ext.create('Ext.form.ComboBox', {
            fieldLabel: 'Reaaaaaaaaaaaaaaallllllllly long',
            labelStyle: 'width:600px',
            //fieldlabelStyle: 'width:600px',//doesn't do anything
            store: states,
            queryMode: 'local',
            displayField: 'name',
            valueField: 'abbr',
            renderTo: Ext.getBody()
        });
    }
});



回答2:


Use labelWidth: config for this. Define like this

 labelWidth: '60%',


来源:https://stackoverflow.com/questions/33003239/how-to-set-extjs-combobox-label-width

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