SharePoint Saturday Belgium slides

April 29th, 2012 | Posted by Marijn in community | demo | events | jquery / javascript

I have to say this SharePoint Saturday was awesome! Thanks to a line-up of world-class speakers, excellent sponsors and a great audience.

Here are my slides and code.

Demo 1

    // hide status field
    $('nobr:contains("Status")').closest('tr').hide();

    // set Cost to readonly
    $(":input[title='cost']").attr('readonly',true);

  //hide the Ferrari option
  var dropdown = $(":input[title='Car']");
  dropdown.find("option[value='Ferrari']").remove();

Demo 2


    // set title value
    $(":input[title='Title']").val("request");

   //get destination from url
    $(":input[title='Destination']").val(getUrlVars()["Destination"]);

function getUrlVars(){
   var vars = [], hash;
   var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
   for(var i = 0; i < hashes.length; i++){
     hash = hashes[i].split('=');
     vars.push(hash[0]);
     vars[hash[0]] = hash[1];
   }
   return vars;
}

// the keyup event
$(":input[title='Distance']").keyup(function(){
    $(":input[title='cost']").val($(":input[title='Distance']").val());
});

Demo 3

function PreSaveAction() {
   //destination has to be filled in
   if ($(":input[title='Destination']").val() == ""){
      alert("Fill in a destination!");
      return false
   }
   return true;
};

Demo 4: Plugins

<script src="/SiteAssets/jquery.SPServices-0.7.1a.js" type="text/javascript"></script>
<script src="/SiteAssets/jquery-ui-1.8.19.custom.min.js" type="text/javascript"></script>
   //the jQuery UI datepicker
   $(":input[title='Day']").datepicker();

   // get current user via SPServices
   $('div.ms-inputuserfield').text($().SPServices.SPGetCurrentUser({fieldName: "Name"}));

Demo 5: Translation

if(_spPageContextInfo.currentLanguage == "1043"){
  $('nobr:contains("From")').text("Van");
  $('nobr:contains("Day")').text("Dag");
  $('nobr:contains("Driver")').text("Bestuurder");
  $('nobr:contains("cost")').text("Kostprijs");
  $('nobr:contains("Request reason")').text("Reden aanvraag");
  $('nobr:contains("Destination")').text("Bestemming");
};

You can follow any responses to this entry through the RSS 2.0 Responses are currently closed, but you can trackback.

%d bloggers like this: