Thursday, December 26, 2013

SharePoint 2013 Rest API Search through List and filter by multiple columns

(1) In the Webpart page, add a script editor webpart
(2) Paste the code shown below in the Editor.
(3) Search the Columns  ( * Filter by word containging the searched word in Column1 or Column2)
(4) Results shown in DataTable
(5) Search results can be filtered through another searchbox.
(6) Changes to be made are Highlighted in blue

Original Post by: Mark Rackley

Search through a list by Column1 or Column2

<!-- jQuery -->
<script type="text/javascript" charset="utf8" src=""></script>
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="">

<!-- DataTables -->
<script type="text/javascript" charset="utf8" src=""></script>
       <input type="text" id="techsearch" >
       <input type="button" value="Search" onclick="LoadTechnologies($('#techsearch').val());" >

<table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="TechTable">
        <th>Name of the Technology</th>
        <th>Green Listed</th>


<script type="text/javascript">

     function LoadTechnologies(techsearch)
       alert("Searching by: " + techsearch + " through Technology Title and Vendor in List Name");
       var call = $.ajax(
                         url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('ListName')/items?$select=Title,Vendor,GreenList&$filter=(substringof('" + techsearch + "', Title) or substringof('" + techsearch + "', Vendor))",
                         type: "GET",
                         dataType: "json",
                         headers: { Accept: "application/json;odata=verbose" }
        );// end ajax

      call.done(function (data,textStatus, jqXHR)
                        "bDestroy": true,
                        "bProcessing": true,
                        "aaData": data.d.results,
                        "aoColumns": [ { "mData": "Title" }, { "mData": "Vendor" }, { "mData": "GreenList" } ]
                        }); //end dataTable
       }); //end call done function
    (jqXHR,textStatus,errorThrown){ alert("Error retrieving Tasks: " + jqXHR.responseText); }); }

Tuesday, December 10, 2013

SharePoint 2013 new Menu bar - Using Script Editor CSS HTML

(1) Create a new sharepoint 2013 web page
(2) Add a script editor web part
(3) Insert the code below in the Script Editor
(4) Using F12 - IE Developer Toolbar identify the right DIV,UL,LI tags and change corresponding styles below.

Thanks to Steve.

<div id="wrap">
    <ul class="navbar">
    <li><a href="#">Home</a></li>
    <li><a href="#">Menu Item 2</a>
       <li><a href="#">2a</a></li>
       <li><a href="#">2b</a></li>
    <li><a href="#">Menu Item 3</a>
       <li><a href="#" >3a</a></li>
    <li><a href="#">Menu Item 4</a>
       <li><a href="#">4a</a></li>
       <li><a href="#">4b</a></li>
       <li><a href="#">4c</a></li>
#wrap {
 width: 100%; /* Spans the width of the page */
 height: 40px;
 margin: 0; /* Ensures there is no space between sides of the screen and the menu */
 z-index: 99; /* Makes sure that your menu remains on top of other page elements */
 position: relative;
 /*background-color: #366b82;*/
.navbar {
 height: 40px;
        padding: 0;
 margin: 0;
 position: absolute; /* Ensures that the menu doesn’t affect other elements */
 border-right: 1px solid #54879d;
.navbar li  {
   height: auto;
   width: 150px;  /* Each menu item is 150px wide */
   float: left;  /* This lines up the menu items horizontally */
   text-align: center;  /* All text is placed in the center of the box */
   list-style: none;  /* Removes the default styling (bullets) for the list */
   font: normal bold 12px/1.2em Arial, Verdana, Helvetica; 
   padding: 0;
   margin: 0;
   background-color: #FFA000;

.navbar a {    
  padding: 18px 0;  /* Adds a padding on the top and bottom so the text appears centered vertically */
  border-left: 1px solid #54879d; /* Creates a border in a slightly lighter shade of blue than the background.  Combined with the right border, this creates a nice effect. */
  border-right: 1px solid #1f5065; /* Creates a border in a slightly darker shade of blue than the background.  Combined with the left border, this creates a nice effect. */
  text-decoration: none;  /* Removes the default hyperlink styling. */
  color: white; /* Text color is white */
  display: block;
.navbar li:hover, a:hover {background-color: #0023a0;}  /*54879d; light blue - #667BC6 */

.navbar li ul  {
  display: none;  /* Hides the drop-down menu */
  height: auto;      
  margin: 0; /* Aligns drop-down box underneath the menu item */
  padding: 0; /* Aligns drop-down box underneath the menu item */

.navbar li:hover ul  {
                        display: block; /* Displays the drop-down box when the menu item is hovered over */

.navbar li ul li {background-color: #0023a0;}   /*54879d */

.navbar li ul li a  {
  border-left: 1px solid #1f5065;
  border-right: 1px solid #1f5065;
  border-top: 1px solid #74a3b7;
  border-bottom: 1px solid #1f5065;
.navbar li ul li a:hover {
  background-color: #667BC6;
  }   /*366b82;   light blue - #667BC6 */