-
25 Jun 2012 2:38 PM #1
Unanswered: View with text from a database
Unanswered: View with text from a database
Hello, I have a view that has text, but I want the text to be pulled from a database using JsonP instead of being hard-coded. I have the JsonP file created, the store and model setup, but am not sure how to get the data to the view. I have not had a problem with doing this type of thing with a data list, but not sure how to without a data list.
This seems like it would be pretty straight forward and easy, but I can't seem to figure it out.
Any help would be so greatly appreciated.
Thanks,
Paul
-
26 Jun 2012 7:25 AM #2
Let's just say we have this code, from Ext.data.proxy.JsonP
Now depending on how your json looks like, you can retrieve the data and the set it as the html in your panel.Code:Ext.define('User',{ extend: 'Ext.data.Model', config:{ fields:['id', 'name', 'email'] } }); var store = Ext.create('Ext.data.Store', { model: 'User', proxy:{ type: 'jsonp', url : 'http://domainB.com/users' } });
Code://example html.json file stored in the folder 'data' [ { html: '... html content here ...' } ]I hope this helps you out.Code:Ext.define('html',{ extend: 'Ext.data.Model', config:{ fields:['html'] } }); var store = Ext.create('Ext.data.Store', { model: 'html', proxy:{ type: 'jsonp', url : '../data/html.json' //you can use a local url here like so }, listeners: { load: function(store, records){ ... //get the view, assuming it is a Panel below (view).setHtml(records[0].get('html')); } } });


Reply With Quote