-
7 Jan 2013 8:31 AM #1
Answered: fieldset setTitle not sticking
Answered: fieldset setTitle not sticking
It's a fairly simple issue. I'm working on the localization of my app. I have just about all of it done, except for the stubborn fieldset titles.
At the same time (before render) that I translate the fieldLabels for the forms inside said feildsets, I do setTitle on the fieldSet. All the fieldLabels get changed without issue, and setTitle does not error out, either. Stepping through with Firebug, I can see that the title was changed in the fieldset object. Then, when the app renders, the fieldset forgets that its title was changed and shows the old title.
I'd rather not change the l10n implementation if I can avoid it.
Can anyone help me out here?
-
Best Answer Posted by Zdeno
I didnt have a time to inspect why setTitle doesnt work in beforerender function. I just simply inspect what does this function do. What I can say now:
1) fieldset isnt rendered yet
2) legend container already exists
Thats why setTitle function does not work. titleCmp is the legend container and update function will update html content of this component.
Instead of f.items.get(0) you can use f.down('fieldset') to find first fieldset element
-
7 Jan 2013 9:14 AM #2
I dont have any problem change title after render. Can you post sample code how do you change the title before render? I think there is the problem why you dont see any changes on fieldset title.
-
7 Jan 2013 10:51 AM #3
After render works for me, but if it's possible to use before render, I would prefer it.
My use case is rather unique. We haven't been good at keeping all the texts in the View layer, so my methods have been pretty bad ...
I have a localization class that changes values of the passed in class. Here is a sample:
A view class Foo's onbeforerender:
Utilities:Code:Utilities.translate(this);
I couldn't put the text in as variables in Architect to be able to more easily dynamically them, so I did it this way. Not all the view classes are available at the same time, so each view has a before render that calls translate(). Texts that aren't in Views are translated using an array also declared in Utilities, but that's besides the point.Code:Utilities.translate = Ext.Function.bind(function(cls){ if (cls.xtype == "Foo") { cls.down("#fieldsetItemId").setTitle("Translation"); // the rest is translated similarly ... } }
-
7 Jan 2013 1:56 PM #4
Try this
Live example: http://jsfiddle.net/fNjgU/1/PHP Code:listeners : {
beforerender : function(form) {
form.items.get(0).titleCmp.update('New title');
}
}
-
8 Jan 2013 7:05 AM #5
My implementation is slightly different. I needed another .items.get(0) in that statement to get it right. I wound up with the same issue; firebug told me on the next line that the titleCmp was updated, but the original title showed up. Also, I don't understand the difference between that suggestion and the setTitle I mentioned originally. According to the fieldset source, setTitle calls titleCmp.update() ...
At this point, I'm starting to think that the problem is rooted in my implementation, which would be why your simple example didn't work in my case. It would probably be less of a headache to just use afterrender than to chase this issue around.
Thanks for your help!
-
8 Jan 2013 7:37 AM #6
I didnt have a time to inspect why setTitle doesnt work in beforerender function. I just simply inspect what does this function do. What I can say now:
1) fieldset isnt rendered yet
2) legend container already exists
Thats why setTitle function does not work. titleCmp is the legend container and update function will update html content of this component.
Instead of f.items.get(0) you can use f.down('fieldset') to find first fieldset element
-
8 Jan 2013 12:48 PM #7


Reply With Quote