Hello,
Below, a simple example to add items to a panel dynamicaly in runtime in Sencha Framework:
1 | var fileName = 'Ext.getCmp(' fileNameHiddenFieldID ').getValue()+' .doc'; |
2 | var myComponentImg1= new Ext.Panel({ |
3 | html: "<a href='file:" +fileName + "'><img src='images/getFile.gif' alt='get File' /></a>" |
5 | Ext.getCmp( 'containerBottomButtonsID' ).add(myComponentImg1); |
6 | Ext.getCmp( 'containerBottomButtonsID' ).doLayout(); |
Notes: The component ‘containerBottomButtonsID’ must have its layout (panel, container..).
For the updating of content in a panel on the fly, a simple example after an ajax request:
01 | Ext.define( 'huo.controller.MyController' , { |
02 | extend: 'Ext.app.Controller' , |
07 | ref: 'documentDetailsSubPanelViewInCtrl' , |
08 | selector: '#documentDetailsSubPanelViewID' |
14 | ,onLaunch: function () { |
16 | var documentDetailsSubPanelViewInCtrl = this .getDocumentDetailsSubPanelViewInCtrl(); |
17 | loadSubPanel(documentDetailsSubPanelViewInCtrl); |
22 | function loadSubPanel(documentDetailsSubPanelViewInCtrl){ |
26 | msg: 'processing data ...' , |
27 | title: ' progress title...' , |
28 | progressText: ' sending processing data...' , |
33 | waitConfig: {interval:200} |
39 | url : 'document.do?action=handleBuildHtmlDocumentWithOutJSON' , |
44 | success: function (request, resp) { |
46 | Ext.MessageBox.hide(); |
49 | var htmlContent = request.responseText; |
50 | documentDetailsSubPanelViewInCtrl.removeAll(); |
51 | documentDetailsSubPanelViewInCtrl.update(htmlContent); |
52 | documentDetailsSubPanelViewInCtrl.doLayout(); |
54 | }, failure: function () { |
56 | Ext.MessageBox.hide(); |
59 | Ext.MessageBox.alert( ' message title...' , ' alert message timeout!!!' ); |
In the previous example, we could replace the updating by adding item in the success callback like:
01 | success: function (request, resp) { |
03 | Ext.MessageBox.hide(); |
06 | var htmlContent = request.responseText; |
07 | documentDetailsSubPanelViewInCtrl.removeAll(); |
08 | var newPanel = new Ext.Panel({ |
14 | documentDetailsSubPanelViewInCtrl.add(newPanel); |
15 | documentDetailsSubPanelViewInCtrl.doLayout(); |
Best regards,
Related
Hi Huseyin,
This really interested.
Can you maybe share a working example on this and send it by e-mail to me?
I want to see the base app setup of this.
Thanks,
Anibal
Hi Anibal,
Thanks for your message.
First, below an example (first part of this post) of the adding of HTML code (hyperlink) to a panel:
1
var
myAhrefLink=
new
Ext.Panel({
2
html:
"<a href='http://www.javablog.fr'>www.javablog.fr</a>"
3
});
4
Ext.getCmp(
'myContainerID'
).add(myComponentImg1);
5
Ext.getCmp(
'myContainerID'
).doLayout();
// important
An example of updating of content in a panel on the fly, could be (second part of this post):
1
var
htmlContent =
"<a href='http://www.javablog.fr'>www.javablog.fr</a>"
2
// Remove all content in panel
3
Ext.getCmp(
'myContainerID'
).removeAll();
4
// Update or Add
5
Ext.getCmp(
'myContainerID'
).update(htmlContent);
6
// Ext.getCmp('myContainerID').add(newPanel);
7
Ext.getCmp(
'myContainerID'
).doLayout();
// Important
I will post a more concrete example on my blog as soon as possible.
However, the visitors of this site could participate to this topic.
Note: you don’t need to have an account to post comment.
Huseyin OZVEREN
What version of Sencha Ext.js is this written in?
Hello Meredith,
From memory, it was the version extjs 4.1.
Kind regards