Hello,
Below, a simple example to add items to a panel dynamicaly in runtime in Sencha Framework:
var fileName = 'Ext.getCmp('fileNameHiddenFieldID').getValue()+'.doc'; var myComponentImg1= new Ext.Panel({ html: "<a href='file:"+fileName +"'><img src='images/getFile.gif' alt='get File' /></a>" }); Ext.getCmp('containerBottomButtonsID').add(myComponentImg1); Ext.getCmp('containerBottomButtonsID').doLayout(); // important
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:
Ext.define('huo.controller.MyController', { extend: 'Ext.app.Controller', [...] ,refs: [ // This is a ComponentQuery selector which finds any component on the page and assigns it to the reference in 'ref' parameter. --> { ref: 'documentDetailsSubPanelViewInCtrl', selector: '#documentDetailsSubPanelViewID' } ] [...] ,onLaunch: function() { // Load the sub panel var documentDetailsSubPanelViewInCtrl = this.getDocumentDetailsSubPanelViewInCtrl(); loadSubPanel(documentDetailsSubPanelViewInCtrl); } [...] } function loadSubPanel(documentDetailsSubPanelViewInCtrl){ // Show a waiting message box Ext.MessageBox.show({ msg: 'processing data ...', title: ' progress title...', progressText: ' sending processing data...', progress: true, closable: false, width:300, wait:true, waitConfig: {interval:200} }); // request the server to check if the filled exist Ext.Ajax.request({ async : true, url : 'document.do?action=handleBuildHtmlDocumentWithOutJSON', method: 'GET', params: { docId:'123' // ID }, success: function(request, resp) { // Hide the waiting message box Ext.MessageBox.hide(); //Ext.MessageBox.close(); var htmlContent = request.responseText; documentDetailsSubPanelViewInCtrl.removeAll(); documentDetailsSubPanelViewInCtrl.update(htmlContent); documentDetailsSubPanelViewInCtrl.doLayout(); }, failure: function() { // Hide the waiting message box Ext.MessageBox.hide(); //Ext.MessageBox.close(); 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:
success: function(request, resp) { // Hide the waiting message box Ext.MessageBox.hide(); //Ext.MessageBox.close(); var htmlContent = request.responseText; documentDetailsSubPanelViewInCtrl.removeAll(); var newPanel = new Ext.Panel({ autoHeight: true, height: '100%', width: '100%', html: htmlContent }); documentDetailsSubPanelViewInCtrl.add(newPanel); documentDetailsSubPanelViewInCtrl.doLayout(); }
Best regards,
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:
An example of updating of content in a panel on the fly, could be (second part of this post):
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