-
3 Mar 2011 12:06 AM #1
Reading CSS values with Ext.util.CSS.getRule
Reading CSS values with Ext.util.CSS.getRule
Let say we have two CSS files, one after the other:
First file with:
and second file with:Code:.ppp{ position:absolute; left:8px; top:80px; width:310px; height:372px; }
then Ext.util.CSS.getRule('.ppp').style.width return no value (NaN).Code:.ppp{ position:absolute; left:8px; top:80px; }
The function fails to go up to the first CSS to read the value.
(I do not want to repeat the values in the second file)
Regards
Philip Arad - Web Architect at SolaredgeLast edited by jsakalos; 3 Mar 2011 at 2:47 AM. Reason: added [code][/code] tags around css
-
3 Mar 2011 2:56 AM #2
.style property of the returned rule is CSSStyleDeclaration. So you need to :
PHP Code:Ext.util.CSS.getRule('.ppp').style.getPropertyValue('width'); // returns "310px"
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
3 Mar 2011 3:41 AM #3
-
3 Mar 2011 4:17 AM #4
Well... Actually it is working if they are in the same CSS file, one after the other, but not working if they are on separate files like:
<link rel="stylesheet" type="text/css" href="custom1.css"/>
<link rel="stylesheet" type="text/css" href="custom2.css"/>
Philip
-
3 Mar 2011 4:21 AM #5
getPropertyValue('width') doesn't work if they are in separate files?
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
3 Mar 2011 4:28 AM #6
Correct. It returns an empty string.
Philip
-
3 Mar 2011 5:15 AM #7
It's strange and unexpected behavior but you're right. I have no idea how to easily resolve it besides repeating the styles in the second file (or putting them only in the second file). I suspect that this is how browsers work, not an Ext issu, nevertheless, if you want you can report it as a bug.
Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
3 Mar 2011 5:21 AM #8
-
7 Mar 2011 12:56 AM #9
This is due to how Ext indexes the style objects associated with the rules.
They are keyed by the selector string, and so when Ext iterates through the stylesheets, it finds a selector ".ppp", and creates an entry in the rules object for it referencing that style object.
If it finds another rule for that selector, the new style object is stored keyed by the same string.
So only the latest one is stored.
I have recently fixed another slight problem in the CSS utility where rules like
could not be found usingCode:.aaa, .bbb { color: red;
because the key associated with that style object is ".aaa, .bbb". We needed to split on "," and create two entries in the rules object.Code:Ext.util.CSS.getRule('.aaa')
It looks like we need to enable each entry to be either a style object or an array of style objects. But then getRule might then return an array, and you would have to interrogate each one in turn to see which one had a non-null style for "width"...
Maybe the problem would be more easily solved by creating a hidden div with class ".ppp", and then asking it what its width is.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
7 Mar 2011 6:34 AM #10
Thank for your reply
First, I have found out that
Ext.util.CSS.getRule('.'+css).style.getPropertyValue('width')
is not working with IE8, so I have to use:
Ext.util.CSS.getRule('.'+css,true).style.width
(I suppose it is true also for other attributes)
As for the CSS problem:
If we have:
andCode:.aaa{ left:8px; top:80px; width:310px; height:372px; }
I would expect one entry:Code:.aaa{ left:2px; top:20px; }
PhilipCode:.aaa{ left:2px; top:20px; width:310px; height:372px; }
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
Ext.util.CSS.getRule
By msinn in forum Ext 3.x: Help & DiscussionReplies: 8Last Post: 1 Feb 2011, 7:33 AM -
Ext.util.CSS.getRule Cross Domain Security Issue
By bobringer in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 28 Jul 2009, 11:26 PM -
[FIXED][3.0.0] Ext.util.CSS.getRule() fails in IE
By ThorstenSuckow in forum Ext 3.x: BugsReplies: 2Last Post: 17 Jul 2009, 9:32 PM -
Reading form values
By hilmi in forum Ext GWT: Help & Discussion (1.x)Replies: 2Last Post: 24 Jul 2008, 1:03 PM -
Reading Java Session Values
By Janachi in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 6 Jun 2008, 12:44 AM


Reply With Quote