With the following code you only need to add MyApp.factory.PopupFactory.showReadonlyPopup(_yourFormpanel_);
to the button's handler.
This code is creating a popup with the content, and adding this to the formpanel, so if you want to open it later on, then it is only replacing the values.
Ext.define('MyApp.factory.PopupFactory', {
singleton:true,
(...)
showReadonlyPopup: function(formpanel) {
var fields = formpanel.getForm().getFields();
if (formpanel.readonlyPopup == null) {
var items = [];
fields.each(function (item) {
if (item.isHidden() == false) {
items.push({
xtype: 'displayfield',
fieldLabel: item.getFieldLabel != null ? item.getFieldLabel() : '',
hideLabel: item.hideLabel,
name: item.name,
labelWidth: item.getLabelWidth(),
value: item.getDisplayValue != null ? item.getDisplayValue() : item.getSubmitValue(),
width: item.getWidth()
});
}
});
var popup = Ext.create('Ext.window.Window', {
title: 'Details...',
closeAction: 'hide',
items: {
xtype: 'form',
layout: formpanel.initialConfig != null ? formpanel.initialConfig.layout : null,
items: items
}
});
formpanel.readonlyPopup = popup;
formpanel.on('destroy', function(form) {
form.readonlyPopup.destroy();
})
} else {
var values = {};
fields.each(function (item) {
values[item.name] = item.getDisplayValue != null ? item.getDisplayValue() : item.getSubmitValue();
});
formpanel.readonlyPopup.down('form').getForm().setValues(values);
}
formpanel.readonlyPopup.show();
}
});