View Full Version : Label from variable

4 Feb 2012, 9:50 AM

I have all my label and title in xx_lang.js but with sencha designer I can't assign them, the tool want a string.

It is possible to do that ?

Thank you,


7 Feb 2012, 10:40 AM
I'm running across the same thing right now. I have variables that I'm trying to plug into the Sencha Designer attributes section and it keeps making it a string. Anybody have a solution to this? This has to be possible somehow with some special syntax or something.

7 Feb 2012, 12:10 PM
It is not possible to use variables in these configurations at this point in time.

7 Feb 2012, 1:24 PM
The general idea I'm trying to accomplish is a simple json API call to one of my cPanel servers. They use an authentication scheme that's similar to many others. If I understand correctly, I need to hash my auth info and pass it in the header during my AJAX call.

My function:

function make_base_auth(user, password) { var tok = user + ':' + pass;
var hash = Base64.encode(tok);
return "Basic " + hash;

How I need to access it:

var auth = make_basic_auth('myuser','mypass_982h3ikuhslkdufy9');

If we can't assign variables to the attributes, then I'm lost as to how I should be using the function I've created. It's probably simple and I'm just not doing it the Sencha way :-?

Additional reference (and where I'm getting my examples):

7 Feb 2012, 1:30 PM
I will agree that its a limitation that you can't assign variables to your ui attributes that you configure through the property grid.

That being said, this code doesnt look like it belongs there at all. You can add a Basic Function (found in the Behaviors group). You will then name it make_base_auth and give it 2 params, user and password. You can then double click on the basic function you've added and paste the body of the code you have here on the forums.

You can then invoke the method via var auth = this.make_base_auth(user, password);

You can choose whether or not you'd like for this method to reside in an Authentication controller or in the LoginForm subclass that you create.

7 Feb 2012, 1:40 PM
We're close...and I had already done much of what you suggested in terms of putting it into a bare-bones function with the necessary parameters. I'm actually trying to access it as part of an AJAX call I'm making with a store.

What I can't figure out is how to get the "auth" variable into the headers section...since it makes it a string. I don't think I can concatenate out, since the entire "headers" value in my AJAX call is encapsulated in single quotes (''). As a result, I'm getting something that looks like this:

Ext.define('MasterPanel.store.base.MyAjaxProxy', { extend: 'Ext.data.proxy.Ajax',

config: {
type: 'ajax',
url: 'url', // hoping maybe to have the "url" variable passed in here as well
headers: '{ Authorization : auth }', // hoping to get "auth" to be a variable
method: 'GET',
reader: {
type: 'json'

Am I totally screwing this idea up? :))

7 Feb 2012, 1:47 PM
So definitions are typically run when the page first loads and before the application executes.

So how is auth going to have any value worth anything? Where did you get the username and password? Unless they are static strings in your JavaScript somewhere this is not going to work.

You need to dynamically set the headers at runtime.

7 Feb 2012, 2:02 PM
Eventually I'll be creating a login mechanism that accepts username, password and hostname fields. Submitting the form will locally store the user's authentication information, and there may be options to store authentication for multiple accounts they may have.

I'll be using the authentication information to access the json REST API on the servers that their hostname matches. Not extremely complicated, but I'll admit...I'm not even sure I'm structuring the application correctly to work within the rules of the Sencha framework (guilty). :-/

7 Feb 2012, 2:09 PM
:-) Sounds like you are on your way.

We are working on the education aspect