PDA

View Full Version : how to pass value to an extjs 4 application from an url



fmuke
2 Nov 2012, 12:57 PM
hi...
i have develloped an extjs 4 application for reporting purpose.

To do the work, this application needs to get some value from asp.net application to work.

i have included the ext js 4 application in part of that asp.net application in a panel trough a an url link

... the panel auto load the link inside itself ....

link has this format :
<AutoLoadrunat="server"Url="http://localhost:52015/AppNow/App.aspx"/>
but this url Url=http://localhost:52015/AppNow/App.aspx?year=2012&customerId=01
do not work.

i understand that passing this value just like this is not supposed to work anyway... but i havent been able to find any info on this
---> below is my app.js... the link is supposed to pass it the customerId along with the year

Core.onPreReady(
function () {
 
});
Core.onReady(
function () {



var homeView = "forwarding-kpi-KpiMultiLine";

Core.context.set(
'yearId', 2011);
Core.context.set(
'customerId', '104trrew000,104ret000');
Core.context.set(
'customer', 'APPLE COMPUTER, US ARMY');
Core.context.set(
'hierarchy', 'Product');

Ext.application({
name:
'AppNow',
enableQuickTips:
true,
controllers: [

'Home',





'AppNow.view.',






],
launch:
function () {

var me = this;
 
Ext.create(
'Core.view.portal.Viewport', {
homeView: homeView
});
}
});
});

mitchellsimoens
5 Nov 2012, 6:46 AM
You can send query params and javascript can get the params from the url. Look at the location.search value

fmuke
5 Nov 2012, 7:40 AM
THI IS THE SOLUTION



var urlLink = document.location.href.split('?')[1];

console.log("This is the link ---> " + urlLink);

var linkvar = Ext.Object.fromQueryString(urlLink);

console.log('customerId --> ' + linkvar.customerId);
console.log('customer ---> ' + linkvar.customer);
console.log('yearId ---> ' + linkvar.yearId);
console.log('hierarchy ---> ' + linkvar.hierarchy);
console.log('homeView ---> ' + linkvar.homeView);

Ext.Object.fromQueryString (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Object-method-fromQueryString)(foo=1&bar=2); // returns {foo: 1, bar: 2} Ext.Object.fromQueryString (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Object-method-fromQueryString)(foo=&bar=2); // returns {foo: null, bar: 2} Ext.Object.fromQueryString (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Object-method-fromQueryString)(some price=%24300); // returns {'some price': '$300'} Ext.Object.fromQueryString (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Object-method-fromQueryString)(colors=red&colors=green&colors=blue); // returns {colors: ['red', 'green', 'blue']} Recursive:

Ext.Object.fromQueryString (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.Object-method-fromQueryString)("username=Jacky&dateOfBirth[day]=1&dateOfBirth[month]=2&dateOfBirth[year]=1911&hobbies[0]=coding&hobbies[1]=eating&hobbies[2]=sleeping&hobbies[3][0]=nested&hobbies[3][1]=stuff", true); // returns { username: 'Jacky', dateOfBirth: { day: '1', month: '2', year: '1911' }, hobbies: ['coding', 'eating', 'sleeping', ['nested', 'stuff']] }