views:

314

answers:

3

hello there,

I would like to know how to add a color to a line in sharepoint 2007 list if in one field there is a specific text contained ?

for example : I have a list that have three fields:

list1

1.id 2.name 3.full description

now i want to show only the first and the second field to the user.

list1

id name


1 abc 2 edv

second thing, i want to give a color (let say red) to a row that contains in the hidden field - "full description", a text with the word for example 'color'.

I found a javascript code that i can add to the aspx page :

(document).ready(function(){ $Text = $("td .ms-vb2:contains('color')"); $Text.parent().css("background-color", "red"); });

but it's only works if the the "full description" is shown.

can someone give me an idea ?

thanks, gadym

A: 

One idea could be to use a calculated column to search the other field for the prescence of your text string - then base the jQuery logic on that calcualted column.

However you mention a description field which is probably defined as "Multiple lines of Text" and these can't be used in calculated columns.

How about outputting the Description field but then using some jQuery to hide it from view with .hide()?

I can't give you the exact javascript to do this right now but if you need any inspiration then Christophe's blog is a great place to start.

Ryan
A: 

From your question I understood that you could highlighted the row which comes a particular text (color) , but couldn't hide that column. In the blow code I have hided that column. You may need to change the column index.

<script>
$(document).ready(function(){ $Text = $("td .ms-vb2:contains('color')"); $Text.parent().css("background-color", "red");
 var myelement = $Text.parent().parent(); 

$(myelement).find("td:nth-child(3)").hide();
$(myelement).find("th:nth-child(4)").hide();
 }); 

</script>

Please let me know, is this helps you?

Hojo
+1  A: 

Have you considered creating a data view with conditional formatting? See http://office.microsoft.com/en-au/sharepointdesigner/HA100996241033.aspx

That way you won't have to do this ugly javascript hacking :)

ArjanP