Stump the Panel » Site Managers and Site Collection Managers

list view format

(8 posts)
  • Started 3 days ago by jaxkookie
  • Latest reply from Christophe
  1. jaxkookie
    Member

    Is there a way to apply a style (color) to a column or columns in a list view, either by column name or column number?

    Posted 3 days ago #
  2. Only if you use a data view web part (XSLT) and SharePoint Designer.

    Posted 3 days ago #
  3. Take a look at this and see if you can tweak it for your needs:
    http://pathtosharepoint.wordpress.com/2008/12/09/color-coding-more-examples/

    Posted 3 days ago #
  4. jaxkookie
    Member

    @laura67, sorry I did not get this the first time you stated that.
    @EndUser, Thanks for the comments. Christophe has a great site, but that post is more closely related to adding color to calculated fields.
    Thanks again

    Posted 3 days ago #
  5. jaxkookie,

    jQuery is all about "find something and do something with it."

    To find a particular column in a List View, use a selector like I did in my Replacing [Today] article:

    $("table.ms-listviewtable:first> tbody> tr:gt(0)").find(">td:eq(3)");

    How it works:
    1. Find the first table with class ms-listviewtable.
    2. Get the child tbody tag.
    3. Get the child TR tags after the first.
    4. In each of those TR tags, find the 4th (count starts at 0) child TD. (skips the header row).

    Then use addClass() to add any class you want.

    Posted 3 days ago #
  6. Well, Mark is correct, you could use the "HTML calculated column" for that. Create a calculated column with this formula:
    = "<div style='background-color:green;'>"&YourColumn&"</div>"

    However, if it may be an overkill here, and Paul's approach seems simpler (although jQuery also seems to be too much, and plain old JavaScript should be good enough).

    Posted 2 days ago #
  7. Christope,
    I'm intrigued! I've never heard of this "HTML calculated column" concept.
    I tried your above example, but the calculated column ends up just displaying the code itself, along with the correct column content where you have put YourColumn in there. Am I missing something? I made the data type "single line of text".

    Laura

    Posted 2 days ago #
  8. Hi Laura,

    for more details follow Mark's link, or see the method explained here:
    http://pathtosharepoint.wordpress.com/2008/09/01/using-calculated-columns-to-write-html/

    The term "HTML calculated column" is just a shortcut to refer to this method.

    My blog actually has 20+ posts on this topic:
    http://pathtosharepoint.wordpress.com/category/the-html-calculated-column/

    Christophe

    Posted 2 days ago #

RSS feed for this topic

Reply

You must log in to post.