-->

Why can not display datas in textfield?

2019-09-10 13:30发布

问题:

Why no data is displayed on the screen? Or tell me a good/correct way to fix or avoid this.

Thank you.

[in view block]

Ext.define('CreditQuery.view.QueryResult', {
extend: 'Ext.tab.Panel',
xtype: 'queryresult',

config: {
    defaults: {
        defaultType: 'textfield'
    },
    items: [{
        title: 'Credit',
        },
        items: [{
            label: 'CustNo',
            name: 'ACCOUNT_ID'
        },{
            label: 'CustName',
            name: 'ACCOUNT_TEXT'
        }]
    }]
}
})

[in controller block]

function setData(data){
data = {
    ACCOUNT_ID: "FN2180004",
    ACCOUNT_TEXT: "John1218"
}

Ext.ComponentQuery.query('queryresult textfield')[0].setValue(data.ACCOUNT_ID);
Ext.ComponentQuery.query('queryresult textfield')[1].setValue(data.ACCOUNT_TEXT);

Ext.ComponentQuery.query('main')[0].push([{ xtype: 'queryresult' }]);
}

回答1:

Access the textfields like this: -

Controller-

refs: {
    customerNumberField : 'textfield[name="ACCOUNT_ID"]',
    customerNameField : 'textfield[name="ACCOUNT_TEXT"]'
}

function setData(data){
 data = {
    ACCOUNT_ID: "FN2180004",
    ACCOUNT_TEXT: "John1218"
 }

 this.getCustomerNumberField().setValue(data.ACCOUNT_ID);
 this.getCustomerNameField().setValue(data.ACCOUNT_TEXT);
}