1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Answers
    1
    Vote Rating
    0
    arleslie is on a distinguished road

      0  

    Default Answered: Dynamic Data adding to defined panel

    Answered: Dynamic Data adding to defined panel


    Hey guys, in a bit of a jam here. I can't seem to figure out how to add items dynamically to a panel that is defined. I've looked at add() but none of my ids or variables accept this. Any ideas?

    Code:
    Ext.define('MyApp.view.Home', {	extend: 'Ext.Panel',
    	xtype: 'Home',
    	
    	config: {
    		fullscreen: true,
    		id: 'HomeView',
    		layout: 'vbox',
    		scrollable: {
    			direction: 'vertical',
    			directionlock: true
    		},
    		items: [
    		{
    			xtype: 'titlebar',
    			docked: 'top',
    			style: "background: url('app/images/header-background.png') repeat-x; height: 44px; border: 0; min-height: 0;",
    			height: 44,
    			title: '....'
    		},
    		{
    			style: "background: #1d2525;",
    			layout: {
    				type: 'vbox',
    				align: 'center'
    			},
    			flex: 1,
    			items: [
    			{
    				id: 'Homepagetext',
    				style: "color: #FFF; font-size: 12pt; padding: 10px;"
    			}]
    		}]
    	}
    });
    
    
    
    
    $.post('app/api.php', {method: "settings", id: "52"}, function(data){
    	data = JSON.parse(data);
    	$('#Homepagetext').html(data.response);
    });
    
    
    $.post('app/api.php', {method: "builder", action: "getSub", id: "0", type:"0"}, function(data){
    	data = JSON.parse(data);
    	for(var i =0; i<data.departments.length; i++){
    		$.post('app/api.php', {method: "builder", action: "view", id: data.departments[i], type: "0"}, function(data2){
    			data2 = JSON.parse(data2);
    			var items = Ext.create('Ext.Panel', {
    				xtype: 'button',
    				text: data2.title
    			});
    			MyApp.view.Home.add([items]);
    			
    		});
    	}
    });

  2. Quote Originally Posted by arleslie View Post
    How would I get my code to create an accessible instance?
    Use ComponentQuery to resolve instances.

    Quote Originally Posted by arleslie View Post
    As well, is there a way to bypass using a PHP pass through?
    Trying to access our API via Javascript throws: Failed to load resource: Origin http://....net is not allowed by Access-Control-Allow-Origin.
    Enable CORS support on the server.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You need to use the add method on an instance not the actual class definition.

    Also, no need to mix frameworks for Ajax requests... just use Ext.Ajax.request()
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Answers
    1
    Vote Rating
    0
    arleslie is on a distinguished road

      0  

    Default


    How would I get my code to create an accessible instance?

    As well, is there a way to bypass using a PHP pass through?
    Trying to access our API via Javascript throws: Failed to load resource: Origin http://....net is not allowed by Access-Control-Allow-Origin.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by arleslie View Post
    How would I get my code to create an accessible instance?
    Use ComponentQuery to resolve instances.

    Quote Originally Posted by arleslie View Post
    As well, is there a way to bypass using a PHP pass through?
    Trying to access our API via Javascript throws: Failed to load resource: Origin http://....net is not allowed by Access-Control-Allow-Origin.
    Enable CORS support on the server.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Answers
    1
    Vote Rating
    0
    arleslie is on a distinguished road

      0  

    Default


    Thanks! I didn't notice that the origin policy applied to the remote server and not the browser. Thanks again!

    Any chance you can remove the link in your answer post? (I couldn't edit it when I posted it)

  7. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Answers
    3447
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by arleslie View Post
    Any chance you can remove the link in your answer post? (I couldn't edit it when I posted it)
    done
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1