-
8 Nov 2011 11:53 AM #1
render data in view from jsnop request
render data in view from jsnop request
Hi Guys,
I am having some issues in rendering a popup. This is what i am trying to achieve. On button click get the value from the text field and pass it as a parameter to the jsonp service. with the result obtained i need to open up the popup window and show the values. Right not i am getting the values from the call back but when i call the resultList.update(data) nothing updates.
Can you guys tell me what i am doing wrong. also if possible can you show me the right method to send a request from a view to a jsonp store with parameters and re-render the data.
Code:var searchText = new Ext.form.Text({ id:'searchText', name: 'searchtext', placeHolder: 'Address, Intersection, Landmark', useClearIcon: true, cls: 'searchText' }); var searchButton = new Ext.Button({ cls: 'search', text: 'Search', handler: function () { var text = Ext.getCmp('searchText').getValue(); GetGeoLocationData(text, ''); popup.show(); // Ext.dispatch({ // controller: parking.controllers.controller, // action: 'showMap', // id: Ext.getCmp('searchText').getValue() // }); } }); var popup = new Ext.Panel({ floating: true, centered: true, modal: true, width: 300, height: 400, dockedItems: [{ xtype: 'toolbar', title: 'PopUp', items: [{ xtype: 'spacer' }, { text: 'Close', handler: function () { popup.hide(); } }] }], item:[resultList] }); var popupResultTemplate = new Ext.XTemplate( '<tpl for=".">', '<div>', '{[this.addCmp{xtype:"radiofield", text:{Representation}, handler:function fn() { alert("ok" + values.id);} }]}', '<div>', '</tpl>' ); var resultList = new Ext.Panel({ id: 'GeoList', scroll: 'vertical', tpl: popupResultTemplate });
The Model
Thanks,Code:parking.stores.GetGeoLocation = new Ext.data.Store({ model: 'parking.models.GeoLocation', autoLoad: true }); var GetGeoLocationData = function (search, optional) { Ext.util.JSONP.request({ url: 'http://parking.511.org/index/M_GetGeoCodeLocation', callbackKey: 'callback', params: { location: search, city: optional }, callback: function (data) { var result = data.Results; resultList.update(result); } }); };
pawan
-
8 Nov 2011 1:54 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
Works... do you get any errors? If not, then simplify your code and start from scratch adding more and more.Code:var panel = new Ext.Panel({ ... tpl : new Ext.XTemplate('<tpl for=".">{test}</tpl>) }); panel.update([ {test : 'One'} ]);Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
8 Nov 2011 2:22 PM #3
Thanks mitchellsimoens, I got it to work. I had made a small structural change in my code. Just one more question Is it possible to dynamically create a xtype in a Xtemplate. some thing like the one shown below. If you could give me a working example it would be really helpfull.
var panel = new Ext.Panel({ ... tpl : new Ext.XTemplate('<tpl for=".">{xtype: "radiofield", label:{test}, value:{}, handler: ext.dispatch()}</tpl>) });
-
9 Nov 2011 4:28 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,684
- Vote Rating
- 435
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
9 Nov 2011 6:48 AM #5


Reply With Quote