Вопрос

var rows=[];
for(var i=0; i<5;i++)
{
    var row = Ext.create(Prototype.view.RowModel);
    var text = row.getComponent(0).getFieldLabel();
    var text2 = row.getComponent(0).getId();
    rows.push(row);
    console.log(text+text2);
}
this.add(rows);

row.GetComponent(0) is confirmed to be a textfield. When I call getFieldLabel() it crashes with the following error

Uncaught TypeError: Object [object Object] has no method 'getFieldLabel' 

But the ExtJs 4.2 documentation says otherwise...? Whatever the technique I use to reach the "label". i always receive a object Object which has no getFieldLabel(). How do I convert? Or reach it directly?

can someone help?

code of the row model :

Ext.define('Prototype.view.RowModel', {
extend: 'Ext.Container',

config: {
    layout: {
        type: 'hbox'
    },
    items: [
        {
            xtype: 'textfield',
            itemId: 'rowLabel',
            width: 100,
            label: 'Vin',
            labelWidth: '100%',
            name: 'rowLabel1',
            readOnly: true
        },
        {
            xtype: 'numberfield',
            itemId: 'UserField',
            width: 100,
            labelWidth: '0%'
        },
        {
            xtype: 'numberfield',
            itemId: 'ObjectField',
            width: 100,
            labelWidth: '0%'
        },
        {
            xtype: 'textfield',
            itemId: 'UnitLabel',
            style: 'font-size:15px',
            width: 60,
            label: 'L/User',
            labelWidth: '100%',
            readOnly: true
        },
        {
            xtype: 'numberfield',
            itemId: 'FactorField',
            width: 100,
            labelWidth: '0%'
        },
        {
            xtype: 'spacer',
            maxWidth: 15
        },
        {
            xtype: 'button',
            handler: function(button, event) {
                alert('help');
                console.log('okay');
            },
            height: 47,
            itemId: 'mybutton',
            ui: 'plain',
            iconCls: 'info'
        }
    ]
}

});
Это было полезно?

Решение

You can find the textfield by itemId:

row.down('#rowLabel');
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top