Adding Color Columns to Sharepoint lists

by Admin 3. November 2008 07:02

I was working on a project that used a sharepoint list with a column called "Urgency" that was a choice column with values "Low", "Medium", "High". The client wanted to show the co0lumn in the list view but instead of the text, show a corresponding color - Green for Low, Orange for medium and Red for High. Also I needed to have this configured without downtime or custom code.

I found a great post online here that helped me do exactly that using a calculated column and a content editor webpart, out of the box!

Steps:

  • Create a column in the list called "Urgency Level" for example. Its a choice column with values "(1) Low", "(2) Medium", "(3) High"
  • Create s column in the list called "Urgency" which will display the color. This is a calculated column. The formula for this column is

          =”<DIV style=’font-weight:bold; font-size:24px; color:”&CHOOSE(RIGHT(LEFT(Urgency Level,2),1),”red”,”orange”,”green”)&”;’>&bull;</DIV>”

  • Add a content editor web part to the bottom of the page and copy the below script into it.


<script type="text/javascript">
var theTDs = document.getElementsByTagName("TD");
var i=0;
var TDContent = " ";
while (i < theTDs.length)
{
try
{
TDContent = theTDs[i].innerText || theTDs[i].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTDs[i].innerHTML = TDContent;
}
}
catch(err){}
i=i+1;
}
//
// ExpGroupRenderData overwrites the default SharePoint function
// This part is needed for collapsed groupings
//
function ExpGroupRenderData(htmlToRender, groupName, isLoaded)
{
var tbody=document.getElementById("tbod"+groupName+"_");
var wrapDiv=document.createElement("DIV");
wrapDiv.innerHTML="<TABLE><TBODY id=\"tbod"+ groupName+"_\" isLoaded=\""+isLoaded+ "\">"+htmlToRender+"</TBODY></TABLE>";
var theTBODYTDs = wrapDiv.getElementsByTagName("TD");
var j=0;
var TDContent = " ";
while (j < theTBODYTDs.length)
{
try
{
TDContent = theTBODYTDs[j].innerText || theTBODYTDs[j].textContent;
if ((TDContent.indexOf("<DIV") == 0) && (TDContent.indexOf("</DIV>") >= 0)) {
theTBODYTDs[j].innerHTML = TDContent;
}
}
catch(err){}
j=j+1;
}
tbody.parentNode.replaceChild(wrapDiv.firstChild.firstChild,tbody);
}
</script>

Thats it! Here was the result:

 

 Also, you would have realised that you can do a lot more than add just colors, you can add any html to be rendered including scripts, mouse overs, colors, images...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

e-commerce | MOSS | Sharepoint

Tool to build WSP solutions for MOSS/Sharepoint Projects

by Admin 11. September 2008 04:46

The tool is called STSDEV. I found it on codeplex. The tool allows you to generate Visual Studio Projects & Solutions to facilitate building of MOSS deployement solutions. Its a simple command line utility that allows you to select the kind of deployment you are trying to do. The hoices include, empty solutions, features, webparts etc. By simply selecting the type of solution and clicking a button, it creates the visual studio project templates for building the WSP. You can drag and drop all of your deployment files into a predefined 12 hive structure. Hitting build on your solution, atomatically create sthe manifest file and builds the wsp. Till now I was building the mannifests and wsps by hand and that is a pain.

There are a number of build configurations generated for you that allow you to retract, deploy, redeploy, install the solutions directly to MOSS without needing to use stsadm. Its a great little tool for development and debugging.

 The project can be found at http://www.codeplex.com/stsdev.

 Here are some sceen casts that are very helpful in getting you started: http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=stsdev&ReleaseId=10119

 

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , ,

.NET | Sharepoint | MOSS

Another iPhone App - Guitar Chords on the iPhone - iChords - http://www.ichords.vishalseth.com

by Admin 29. July 2008 13:47

Ok, I added another one. This one is a great app that allows you to find almost any guitar chords by name. Not only that, it allows for finding many variations of the same chord, left handed and right handed chords, different tuning scales etc. the url is http://www.iphone.vishalseth.com. I just submitted it on Apple's website and will post a link to the listing when it shows up.

Currently rated 4.3 by 4 people

  • Currently 4.25/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , ,

.NET | C# | iPhone | iPod

Adding AdSense on an Office Live Site

by Admin 23. July 2008 14:10

I recently tried to add google adsense ads on my office live page at http://www.vishalseth.net. It wasn't straightforward but you can do it. Initially, I saw the HTML module available in the site designer and thought I could just use that; but if you've tried it that doesnt work either... or atleast did not work for me. I had to use an iframe... This is what I finally did to make it work:

  1. Create an empty html file e.g. AdSense.htm on my computer
  2. paste the AdSense code from google including the script tags into the htm file using notepad. The html file at this point only contains the code in the script tags and nothing else (no <html>, <head> or <body> tags either.)
  3. save and close the file
  4. upload the file to to your documents folder in your office live account. when logged into site builder, the link to the document library should be available on the left. Clicking on it should alloow you to upload any files into the library.
  5. in the site builder, open the page onto which you wish to add the adsense ads. add a html module onto the page.
  6. for the html, insert the following: <iframe  frameborder="0" scrolling="no" src="http://yoursite.com/Documents/adsense.htm" width="770" height="110"></iframe>. Save.
    1. yoursite.com is the base url of your site
    2. height, width can be set to suit the dimensions of the ads you're displaying.

The ads should now be visible on your site...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

.NET | General | office live

iPhone App - iNGPOD - National Geographic Magazine's photo of the day.

by Admin 22. July 2008 05:24

This iPhone development thing is addictive. seriously. It's hard for me to have a little time on my hands and not want to write another fun app that shows up on my home screen. This one just pulls and displays the Photo of the day from National Geographic Magazine's website. It's something I have on my google home screen and just like to look at daily and thought it would be fun if I could have it on my phone as well. The url is http://www.iNGPOD.vishalseth.com. You can see it published in Apple's web application directory by clicking here 

 Update: The application is offline for now due to problems with making httprequests in my medium trust hosting environment.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , , ,

.NET | C# | General | iPhone | iPod

Another new iPhone App - iSigns - Mobile Horoscopes from astrology.com

by Admin 21. July 2008 04:18

I created a new app this weekend because I had a little bit of time. My wife likes to check her daily horoscope on astrology.com and I thought it would be cool if I could make an app that shows the daily horoscope. Whats even better is that they have daily horoscopes in many different categories like for example, general, health, couples, singles, home & garden, work and even a baby, dog and cat horoscope! Now I can just pull up the daily horosocopes anytime; kind of fun. I just submitted the app on apple's iPhone webapps directory so I'll post a link to the listing when it appears. Meanwhile, the link to the app, if you want it on your phone is, http://www.iSigns.vishalseth.com. For now its only customized to the apple mobile safari browser.

Update: See the application published in apple's web app directory by clicking here.

 

 Update: The application is offline for now due to problems with making httprequests in my medium trust hosting environment.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , , ,

.NET | C# | iPhone | iPod

The e-Salesman Paper

by Admin 11. July 2008 07:39

This is a link to a paper I published as part of my coursework at San Jose State. http://ieeexplore.ieee.org/xpl/freeabs_all.jsp?tp=&arnumber=1286466&isnumber=28682

Abstract:
Current e-commerce Web sites employ designs that are catalog based. Most Web-stores are seen to be fancy displays of product catalogs. The drawback is that customers are easily confused with the number of links available; they have to go through complex navigation and keyword searches to find their products; and solely rely on their own decision to purchase a product. Additionally, they cannot distinguish one retailer from another based on the Web-front; identity of the Web-business is lost. Hence, there is a lack of trust. The human and personal element seen in traditional shopping is also lost when shopping online. This paper discusses and proposes an intelligent solution to these problems. The e-Salesman System (eSS) aims to simulate the human element of traditional shopping for online sales. It is based on a knowledge driven, intelligent model as opposed to a catalog based, and static model. It is supported by a framework that is easily extensible and customizable to the needs of any Web-store.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , , ,

.NET | General | e-commerce

Visual Studio 2008 Keyboard Shortcuts

by Admin 10. July 2008 15:14

I love my favourite visual studio shortcuts while I'm coding. Today I was actually thinking just that and wondered how many shortcuts there actually are. I ran a macro to spit out the shortcuts into an html file and this is what I came up with: http://www.vishalseth.com/page/Visual-Studio-2008-Keyboard-Shortcuts.aspx.

I knew there were a lot but I did not know that there were that many!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

.NET | Visual Studio | C#

New iPhone App - PocketBar - http://www.pocketbar.vishalseth.com

by Admin 10. July 2008 13:48

PocketBar - http://www.pocketbar.vishalseth.comLong story short; I bought an iPhone, saw that apple had a webkit for building web apps and wanted to experiment with creating a web application in ASP.Net to run on the iPhone & iPod touch. Also extended it recently to work on a desktop browser so if you navigate to it using a desktop browser, you'll see the desktop version. To see the mobile version navigate to it using an iPhone or iPod touch.

I submitted it to the apple mobile web apps directory; you can see it published here.

Its a nifty little app; simple but seems to be quite popular ;) Basically its just a database of online cocktail recipes accessible on the iPhone & iPod Touch. It also has a nice little icon that you can add to the home screen of your mobile device to start it up automatically when you click on it.

The url for the app is http://pocketbar.vishalseth.com

Here's a screen shot of what it looks like on the phone.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , ,

.NET | General | iPhone

Dynamic SQL - sp_executesql

by Admin 10. July 2008 11:54

There are times when you just can’t avoid using dynamic SQL. Usually this is happens when you end up working with a poorly designed database backend. All developers have done it at some point of time and creation and execution of dynamic sql through business code is commonly seen. In TSQL, I’ve also seen many using the EXEC command to execute the dynamic sql. TOday, I found something I didn’t know about which is sp_executesql.

 sp_executesql came in SQL server 7 . You can use it not only to execute dynamic sql but what makes it great is that you can pass to your dynamic sql, parameters and yes… a parameter may be an out parameter!

 syntax: sp_executesql @stmt, @params, [@paramvalue1, @paramvalue2…]

Crude example:

DECLARE @TblName varchar(50)
DECLARE @ColValue int
set @ColValue=30 
set @tblName='MyTable'
sp_executesql 'Select * from ' + @MyTable +' where somecol = @ColVal' , '@ColVal int', @ColValue

Crude example with an out parameter:

DECLARE @TblName varchar(50)
DECLARE @ColValue int
DECLARE @CountReturned int
set @ColValue=30 
set @tblName='MyTable'
sp_executesql 'Select @Count = count (*) from ' + @MyTable +' where somecol = @ColVal' , '@ColVal int, @Count int out', @ColValue, @Count=@CountReturned output

Here is a great article on dynamic SQL :http://www.sommarskog.se/dynamic_sql.html

Currently rated 3.0 by 1 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

SQL

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen