views:

66

answers:

2

The place were I wnat to use the YUI DataTable is in a wiki that allows HTML and javascript. I have created the custom table, put it in a div and gave it an ID and it works really well except that it usees the CSS from the container wiki page and visually it is not presentable. I would like to be able to set the CSS information for this particular table so that it is more readable. As you might guess I cannot modify the "head" information as the wiki only allows me to add things to the "body" of the html. I am by no means an expert in html and as such I am not sure if can specify CSS for a one table?

I was looking around in the YUI documentation to see if there was a mechansim in the YUI DataTable to set the CSS type of information but I could not really find anything. It seems like I should be able to set it in the oConfig object I pass to the table when it is created. So if someone knows of a way to do it using the YUI DataTable parameters that would be appreciated as well.

+1  A: 

Put your datatable in a specific div with an id

Or: Via the css selector : #yourdivid .yui-dt-data

Gregoire
I forgot to mention it. It already is in a specific div with an id. So how do I set the CSS for that specific div without access to the head? Sorry if this is a nobee question...
stephenmm
+1  A: 

Can you run Javascript in the page? If so, then you can dynamically add a css link to the page without access to the element.

Here's how from the open source Timeline project:

    // Use document for the doc param

    function includeCssFile(doc, url) {
    if (doc.body == null) {
        try {
            doc.write("<link rel='stylesheet' href='" + url + "' type='text/css'/>");
            return;
        } catch (e) {
            // fall through
        }
    }

    var link = doc.createElement("link");
    link.setAttribute("rel", "stylesheet");
    link.setAttribute("type", "text/css");
    link.setAttribute("href", url);
    getHead(doc).appendChild(link);
};

function getHead(doc) {
    return doc.getElementsByTagName("head")[0];
};
Larry K
Yes I can run javascript. I am not sure I understand what is going on in your example yet but I will look through it some more and try and understand it. I am finding my understanding of CSS is about nill...
stephenmm
The software adds a link to a css file to an html file without needing access to the html file's head section. The css file would include the css rules for your YUI table. That way you can style the YUI table as you want.
Larry K
Really! Wow, that is pretty darn cool. Thanks a ton for this.. I will have to try it when I get some time as this is not my main priorety. Thanks again.
stephenmm