Reputation: 13499
If I have a form in extjs I can get the data using this
var values = form.getValues();
Unfortunately this only returns fields which are enabled. I also have fields which are disabled. For example I have an ID field which is disabled, because obviously you do not want to modify the ID. So the getValues() method is pretty useless IMO.
There is also getRecord().data which gives me all the values in the form.
form.getRecord().data
Great! But all the data is out of data, and it doesn't reflect modifications done in the form.
I looked at getFieldValues() too, but again this only gives me values of fields that are enabled.
Is there any method out there that will give me exactly all the data in the form as is on the screen? or do I have to write a huge hack to give myself this functionality?
Upvotes: 0
Views: 4046
Reputation: 4987
If you want to simulate disabled fields, you can have the following CSS class:
.textFieldDisabled .x-form-text {
background-color: #B1B2B4;
background-image: none;
}
And have this in your view markup:
{
xtype: 'textfield',
fieldLabel: 'User ID',
name: 'UserID',
readOnly: true,
cls: 'textFieldDisabled '
}
getValues()
will return the value for this field and it'll look disabled to the user.
Upvotes: 1
Reputation: 300
Set the fields to readOnly instead of disabled.
Or do this with a component Query:
var form = formpnl.getForm();
var disableditems = formpnl.query('[disabled=true]');
Ext.each(disableditems, function(item) { item.enable(); });
var values = form.getValues();
Ext.each(disableditems, function(item) { item.disable(); });
console.log(values);
Upvotes: 7