PDA

View Full Version : Set values based on URL parameters?



charlie17
11 Feb 2013, 1:14 PM
I have a panel view, with a bunch of components, in a JS file which is embedded in an HTML page. One of those components is a multislider, and I would like its two values to be set based on parameters passed in from a source URL.


So for example if the URL used to access the page is


www.domain.com/controls.html?multi1=4&multi2=9

then the multislider values would be set to 4 and 9 accordingly.

What is the best way to go about this?

evant
11 Feb 2013, 1:30 PM
You can use this to grab the data from the query string:

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Object-method-fromQueryString



// strip the leading ? if it exists.
var keys = Ext.Object.fromQueryString(window.location.search.substring(1));

// later
values: [keys.multi1, keys.multi2]

charlie17
12 Feb 2013, 8:06 AM
Thanks Evan - got it working.

A semi-related question. I also have a grid on this page and will query a DB to populate it. Is there also a quick way within ExtJS that I can grab the query string that is built by the proxy and sent to my PHP file? i.e. programmatically grab the GET or POST data?