[ 4 posts ]

Tony Lee

  • Username: young81k
  • Joined: Mon Aug 13, 2012 7:14 am
  • Posts: 2
  • Offline
  • Profile

Getting the CSS source for table column width

Post Posted: Mon Aug 13, 2012 8:32 am
+0-
This has been driving me nuts for the past couple of days. I am using YUI 2 datatable for developing a a WebApp for managing local/remote files. Since I am trying to tweak its style as I see fit for the app, I would like to know how I can get the width of the each column of the table (along with other style attributes) using javascript. Looking at it via Firebug, it seems like the table's column width is defined at "index.html#4", but I can't seem to access and gather the css content from this so-called CSS location at "index.html#4". So my question is:

1) How are these CSS sources, "index.html#1, #2, #3..." being created?
2) Can I access and gather the css content from these dynamically created CSS sources using javascript? if so, how?
3) If it's not possible, do you recommend any other method for gathering the styles defined at these #1, 2,3 css sources?

I apologize if you find this question stupid. I am really really new to using YUI datatable, and this is my first time doing any kind of development with it. I will continue to read through the available resources out there, but I thought I should ask others who could point me to the right direction :)

Thank you in advance!

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Getting the CSS source for table column width

Post Posted: Mon Aug 13, 2012 9:38 am
+0-
I really don't know where you got that index.html#4 or whatever, they are not stylesheets for all I know. The column with is not set by any style sheet belonging to DataTable. As with any table, plain HTML table or YUI's DataTable, the column width is determined by its content, unless you explicitly force any width either via a CSS style declaration of your own or by the width attribute on a column definition. If you don't do it explicitly, the DataTable will just adjust to accommodate its contents.

If you later want to determine what width turned out, you could use any of the YUI Dom tools to read the width from any of the cells, which you can easily get by calling DataTable's getTdEl or, better yet, getThEl. I suggest you use the YAHOO.uti.Dom.getRegion on the header cells (getThEl) since getRegion already returns an integer with all the actual sizes resolved to pixels while, if you get the results of the CSS styles, it might give you pixels, ems, points, cm or just say 'auto' and then you would have to figure out what that means.

There are a series of tutorials recommended in the highlights of DataTable's user Guide, it would be a good idea if you read them. This is also a good source of DataTable tips and tricks: http://satyam.com.ar/yui

Tony Lee

  • Username: young81k
  • Joined: Mon Aug 13, 2012 7:14 am
  • Posts: 2
  • Offline
  • Profile

Re: Getting the CSS source for table column width

Post Posted: Mon Aug 13, 2012 10:35 am
+0-
Here's the screenshot of the firebug view that shows the index.html#4 as the css source. As a matter fact, the width is being explicitly defined and they are readjusted as on window resize. I could just specifically call for the width of the each column of the table with javascript, but I am reluctant in doing so because I want to make sure to capture all style attributes (Not just width) defined in these #Num CSS sources.

Image

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Getting the CSS source for table column width

Post Posted: Mon Aug 13, 2012 1:08 pm
+0-
That style is not part of the Datatable distribution files, it is part of the example and it is one of the ways you could customize the table yourself.

Every cell of each of the columns gets a className derived from the ".yui-dt" prefix, then the ordinal number of the DataTable instance within that page, then "-col-" and finally, the key of the column.

In this particular example, the author wanted to assign those specific CSS styles to the column for field "file" of the eight datatable in the page.

this is specific to this example, and so is the file it is contained within. This is not part of DataTable.
  [ 4 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum