how to add a color to a line in sharepoint 2007 list that has a specific text?

廉价感情. 提交于 2019-12-11 08:09:53

问题


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


回答1:


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 :)




回答2:


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.




回答3:


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?



来源:https://stackoverflow.com/questions/2424117/how-to-add-a-color-to-a-line-in-sharepoint-2007-list-that-has-a-specific-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!