I am passing a record in from the controller via:
showDetail: function (list, record) {
this.getMain().push({
xtype: 'leaddetail',
data: record.data
});
},
My View:
Ext.define('ApexChat.view.LeadDetail', {
extend: 'Ext.Panel',
xtype: 'leaddetail',
init: function() {
debugger;
},
config: {
styleHtmlContent: true,
scrollable: 'vertical',
title: 'Details',
frame: true,
labelwidth: 75,
items: [
{
xtype: 'fieldset',
columnWidth: 0.5,
collapsible: true,
title: 'Lead Information',
defaultType: 'textfield',
defaults: { anchor: '100%' },
layout: 'vbox',
items: [
{
fieldLabel: 'Name',
name: 'name',
tpl: '{name}',
value: '{name}',
disabled: true
},
{
fieldLabel: 'Email',
name: 'email',
value: '{email}',
disabled: true
},
{
fieldLabel: 'Phone',
name: 'phone',
value: '{phone}',
disabled: true
}
]
},
{
xtype: 'fieldset',
columnWidth: 0.5,
collapsible: true,
title: 'Exta Information',
defaultType: 'textfield',
defaults: { anchor: '100%' },
layout: 'vbox',
items: [
{
fieldLabel: 'Company Key',
name: 'companykey',
value: '{companyKey}',
disabled: true
},
{
fieldLabel: 'Chat ID',
name: 'chatid',
value: '{chatId}',
disabled: true
},
{
fieldtype: 'textarea',
fieldLabel: 'Notes',
name: 'notes',
value: '{notes}',
disabled: true
}
]
}
]
}
});
But inside the textfields i still see {companyName}
Assuming it cant be done like that, so how do I access the record being passed from the controller so I can do a .get('name') or something similar to that?
tpl
anddata
are used for rendering custom HTML, while Ext fields are components that handle their own rendering. You shouldn't have to touch theirtpl
, except for advanced use cases.As opposed to other frameworks that are mainly based on HTML templates, Ext is essentially a object oriented component library. You rarely go to the HTML level yourself.
For setting the values of a bunch of fields at once, you need to put them in a
Ext.form.Panel
. Then you can usesetValues
or, maybe more appropriated in your case,setRecord
.Using your example, you would configure your fields this way:
Then you can assign your record at creation time using the
record
config option:Or you can use the methods to load the data: