How to read query string in ExtJS 4?

Go To StackoverFlow.com

12

I have an ExtJS application which is invoked with some query string parameters. I would like to know how to read those parameters and their values using ExtJS 4.

My ExtJS application URL will look like the following:

http://localhost:8080/myapp?candidate_id=101&candidate_id=102&candidate_id=103
2012-04-04 06:13
by Shekhar
@EvanTrimboli, that question is related to jquery...not about extjs - Shekhar 2012-04-04 06:40


19

You can use Ext.Object.fromQueryString like this Ext.Object.fromQueryString('candidate_id=101&candidate_id=102&candidate_id=103')

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

2012-04-04 06:34
by Özgür Kara
but 'candidateid=101&candidateid=102&candidateid=103' this part is not static. it will keep changing i.e. number of times candidateid mentioned in querystring can change from 3 to 10 or - Shekhar 2012-04-04 06:39
you can get your query string by document.location.href.split('?')[1], so you can use this value to for fromQueryString method. this method will give you an object. if candidate_id mentioned more than once it will give you an array for candidate_idÖzgür Kara 2012-04-04 06:44
Use location.search to pass the parameters to Ext.Object.fromQueryStringJaider 2012-10-24 15:14
Using document.location.search has a big advantage over using document.location.href.split(?). If no search part is given in the url like in http://www.google.de the split will return an undefined. This will lead to an exception in the Ext.Object.fromQueryString method. Using document.location.search will return an empty string and will not crash when no search path is provided! Thx Jaide - Chris 2013-03-31 13:37
Ads