PDA

View Full Version : Communicate Extjs



saadkhan
27 Feb 2010, 7:24 AM
Hello,
I have made flex application (google map) which I want to embed to my same aspx page as Extjs script is running. I have a script file named Core.js that is included to Index.aspx page which renders whole page:



var routeStore;
function RecieveRouteXML(str) {
routeStore.proxy.data = StringToXml(str);
routeStore.load();
}

function StringToXml(str)
{
var doc;
if (window.ActiveXObject)
{
var doc = new ActiveXObject("Microsoft.XMLDOM");
doc.async = "false";
doc.loadXML(str);
return doc;
}
else
{
var doc = new DOMParser().parseFromString(str,"text/xml");
return doc;
}
}


Ext.onReady(function() {
routeStore = new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(''),
reader: new Ext.data.XmlReader(
{
record: 'Point'
},
[
{name: 'Location', mapping: '@Location'},
{name: 'Speed', mapping: '@Speed'},
{name: 'DateAndTime', mapping: '@DateAndTime'},
{name: 'Latitude', mapping: '@Latitude'},
{name: 'Longitude', mapping: '@Longitude'}
])
});

var routeGrid = new Ext.grid.GridPanel({
title: 'Route',
store: routeStore,
hideHeaders: true,
columns:
[
{id: 'location', header: "Location", dataIndex: 'Location', renderer: function(value,p,r){ return String.format("<b>{0}</b><br />{1}<br />{2}<br />{3}, {4}", value, r.data['Speed'], r.data['DateAndTime'], r.data['Latitude'], r.data['Longitude']); }}
],
autoExpandColumn: 'location',
viewConfig:{ forceFit: true }
});
}


Function 'RecieveRouteXML' is receiving data (xml) from Flex app but it finds routeStore to be 'undefined', however page used to already been rendered. I have checked that this object is well defined and use to load fine when I manually calls this function by any means (like on button click event).....
I have checked that this function is called by flex and data receives!!!

When I hosts flex app on my same .aspx page, it also throws Ext is undefined (but page renders and works fine)....

Please help me on why is my 'routeStore' object finds to be undefined when flex calls this function????

fay
27 Feb 2010, 7:47 AM
First off, you don't need to use global variables like "var routeStore;" - you can access the store via Ext.StoreMgr (http://www.extjs.com/deploy/dev/docs/?class=Ext.StoreMgr) if you provide it with a storeId:


function RecieveRouteXML(str)
{
var ds = Ext.StoreMgr.get('routeStore');
// ...
}

//...

Ext.onReady(function() {
var routeStore = new Ext.data.Store({
storeId: 'routeStore',
proxy: new Ext.data.MemoryProxy(''),
// ...

RE:


When I hosts flex app on my same .aspx page, it also throws Ext is undefined (but page renders and works fine)....

Without seeing how you've set up your page, it's impossible to tell what's going on.

tobiu
27 Feb 2010, 8:13 AM
NEVER EVER spam one topic 3 times in the help-forums!

at least i won't answer persons who do it.



without kind regards,
tobiu

saadkhan
27 Feb 2010, 8:14 AM
Hey thanksssssss aloottttttt Fay......it solved my problem!!!!
Now my store automatically gets updated when function is called from Flex app.
And i checked about that 'Ext undefined' error message, it was because of some mistakes i made in flex application. So, it all fine now...thanks once again! :D

saadkhan
27 Feb 2010, 8:25 AM
Sorry Tobiu.....now i realized how this thread got spammed. Actually, I stopped my browser twice to edit my first question and didnt realized about it...sorry!

tobiu
27 Feb 2010, 8:27 AM
you can easily edit your own postings after submitting them.
even multiple times.