Wednesday, July 31, 2013

Displaying multiple parameter values in a Crystal Report

When a Crystal report user chooses multiple values for a parameter, sometime it's nice to display all those parameter values in the report header. The following code can be added to a function for displaying in the header.

WhilePrintingRecords;
StringVar Array term := {?Term};
StringVar terms := term[1];
Local NumberVar i;
For i := 2 To count(term) Do
(
   terms := terms + ", " + term[i];
);
terms

Tuesday, July 2, 2013

Including a link to a javascript file in XSLT

In SharePoint 2010, I was updating a custom version of the ContentQueryMain.xsl file, needing to include javascript for the page. When I added the following code, the layout of the page changed, the ribbon stopped responding and the page would not respond when in edit mode.

<script type="text/javascript" src="/Script%20Files/myjavascript.js"></script> 

Turns out, the XSLT processor didn't care for the empty script tag. Adding the space entity &#160; fixed the problem.

<script type="text/javascript" src="/Script%20Files/myjavascript.js">&#160;</script>

 

Tuesday, May 7, 2013

Using VLOOKUP in a Google Spreadsheet for adding new rows through form submission


In order to have a VLOOKUP formula apply to new rows added to a Google spreadsheet through form submission, add the following formula to a 2nd row column (below the header).

=arrayformula(vlookup(B2:B,Names!$A$1:$B$360,{2}*sign(row(B2:B)),FALSE))

The first argument of vlookup is the range of cells for your lookup values.
The second argument is your table array. This example uses a 2-column table array.
The third argument is the column index number. The use of the formula 'sign' is key to make an array that is the same length as the first argument.
The fourth argument is a boolean value that specifies whether you want vlookup to find an exact match or an approximate match.

Monday, April 22, 2013

Using CSS Direct Descendant Selector with Tables

Recently I was attempting to use a  CSS 'direct descendant' selector (>) to set a bottom border on rows in a table. Because there were rows buried deeper in nested tables, I didn't want those to have the border. When I used the following CSS selector, it didn't work.

   table.employee > tr

Turns out, I needed to add a TBODY between the TABLE and TR, even though a TBODY was not showing in the page source because the TBODY is implictly added.


table.employee > tbody > tr
 
 

Thursday, April 4, 2013

Using Request.QueryString in Page_Load in SharePoint page layout


Below is an example of using the Request.QueryString collection in the Page_Load method in a SharePoint page layout. In this case we're looking for the variable named 'tab' and checking for various conditions.


try
{
  int index = System.Convert.ToInt32(Request.QueryString["tab"]);
  if (index > 1 && index < 5)
  {
    if (RadTabStrip1.Tabs[index-1].Visible)
    {
       RadTabStrip1.Tabs[index-1].Selected = true;
       RadMultiPage1.PageViews[index-1].Selected = true;
    }
  }
}
catch (Exception ex)
{
  //    Response.Write(ex.Message);
}

Thursday, March 28, 2013

Using word-wrap for an AspMenu SharePoint web control with long menu items

I have an AspMenu SharePoint web control with long menu items that do not respect the width of the table cell that I've set even though I have the property 'ItemWrap' set to 'True'. The biggest culprit is users wanting to use a series of  underscores to separate one group od links from another. To keep an extra long series of underscores from pushing the table cell wider, I'm using the stylesheet rule 'word-wrap' as shown below.

The ASPMenu control creates this hierarchy of tables. 

div#s4-leftpanel table tr td table
{
       table-layout:fixed;
}
div#s4-leftpanel table tr td table tr td
{
       word-wrap:break-word;
}

Monday, March 11, 2013

Hiding SharePoint list columns from NewForm.aspx using JavaScript

There are times I create a column in a SharePoint custom list and I don't want anyone with Contribute rights to alter the default value. In the NewForm.aspx and EditForm.aspx pages I add the following script to a CEWP on the page.

<script type="text/javascript">
  function HideField(title){
   var header_h3 = document.getElementsByTagName("h3");
   for (var i = 0; i < header_h3.length; i++)
   {
       var el = header_h3[i];
       var foundField;
       if (el.className=="ms-standardheader")
       {
           for (var j=0; j<el.childNodes.length; j++)
           {
              if (el.childNodes[j].innerHTML == title || el.childNodes[j].nodeValue == title)
             {
                 var elRow = el.parentNode.parentNode;
                 elRow.style.display = "none"; //and hide the row
                 foundField = true;
                 break;
         }
      }       
    }
     if (foundField)
  break;
 }
}
HideField("Workspace");
HideField("Remote Item ID");
</script>