Reputation: 832
So I am working on legacy code. I have a grid that has an action button, when clicking this action button, it must enable the user to rename a certain value, change another field etc...
The problem I am facing is that when I click the edit button, I can see in the console, that it is selecting the correct data and sending it to the form panel, but the form panel keeps displaying the firs selections data. How to fix this???
Some code:
// the filed that needs to display the newly selected rows data
items:[
{
xtype: 'displayfield',
fieldLabel: 'Route',
id: 'route',
name: 'route'
}
...
Ext.getCmp('route').setValue( /** currently selected rows route **/ );
No matter what, it keeps on displaying values it first bound to, however in the console I can see the values change. I have even tried resetting the form after the submit and cancel methods.
Upvotes: 1
Views: 2792
Reputation: 832
In the end I used a combination of your answers. On the click of the action button, I created a new form, as Joe suggested and then set the values of the different input fields. To ensure that no data was kept and that each event loads the corresponding rows data I did as Mohit suggested, and destroyed the form after submit/cancel. So each button creates and destroys a form.
Upvotes: 1
Reputation: 1449
Destroy your formPanel when click on cancel button then check.
Upvotes: 1
Reputation: 443
Maybe you can try with javascript variable instead of DOM/component selector.
var routeField = Ext.create({
xtype: 'displayfield',
fieldLabel: 'Route',
name: 'route'
});
....
items:[routeField]
....
routeField.setValue('A1');
Upvotes: 1