Results 1 to 6 of 6

Thread: Dynamic Data adding to defined panel

  1. #1
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Answers
    1
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Answers
    1
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  6. #5
    Sencha User
    Join Date
    May 2013
    Posts
    22
    Answers
    1
    Vote Rating
    0
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •