PDA

View Full Version : Dynamically Change Label and style of Slider



arnoldvillasanta
9 Dec 2014, 12:02 AM
I'm in Extjs 4.2 and I found these two solutions that works to dynamically change label and style of slider component:


slider.setFieldLabel('Approved');
slider.labelEl.update('Approved');


And there are other solutions way past version 3.0 which I have tried but failed to understand.

While I had problem finding the solution to change Styles dynamically for slider (either thru styles/cssClass). I have chosen so far the below code as it somewhat 'match' the 2nd option above.



slider.labelEl.setStyle('color', '#00CCFF');



My dilemma right now is when I'm hitting a wall like this, it will take a lot of time finding a solution that works (in version 4.2)... And yet, after finding one that works, I still don't know if that is 'the standard' for that version as well.

I found that some methods in 4.2 are 'wrappers' or 'convenience code', which is not well described if that is really for 'convenience' only... or it brings performance enhancement as well.

I found personal sites of sencha support engineers and some other premium members very informative and helpful. I hope Sencha will have, at least' a 'page' in their site to point to these resources, harnessing all available (valid) solutions, indexing them, and providing some 'search engine'... an E-learning hub of some sort.

Thanks in advance.

Gary Schlosberg
9 Dec 2014, 5:20 AM
Regarding the sharing of information, I'd say that posting your results here on the forum is the best bet. It is easily searchable and somewhere that folks are accustomed to looking for things. Every time a user shares an experience like yours or asks a question the forum grows stronger.

arnoldvillasanta
20 Dec 2014, 4:52 AM
Noted Gary, thanks.

With regards to my other question on performance, I think it's up to me to dig into ExtJS documentation and codes... and from there decide if I should use the wrapper methods (with all its error-handling codes)... or should I use the 'core' of the wrapper methods and handle all the validations and checks on my own.


I'm just wondering (for the sake of discussion):

Why Sencha wrapped inputEl.applyStyles(style) inside setFieldStyle(style)...
while labelEl.applyStyles(style) is not wrapped inside setLabelStyle(style)?

For all non-wrapped methods, developers tend to access component's private object to be able to call the private object's private method just like labelEl.applyStyles(style).

I believe Sencha is discouraging developers to access "private methods" for future-proofing the application... but I don't know if that also stands for "private objects"...
applyStyles(style) is a method of the private object Ext.dom.AbstractElement according to SenchaDoc.

On the other hand, if Sencha believes that
addCls(), removeCls() and replaceCls()
is better than wrapping methods that call applyStyles() or setStyles(),
then it should be in the document (under the method description) and in the Architect (as a warning in the source panel).