HOME SUBSCRIPTION SHOPPING PHOTO GALLERY VIDEOS MUSIC DOWNLOADS MY MANORAMA BLOG CHAT MAIL  Unable to read?
» Make Us Your Home Page 
SEARCH google WEB MANORAMA REGISTER NOW           
    ഇന്‍ഫോര്‍മേഷന്‍ ടെക്നോളജി ബ്ലോഗ് - ഡിജിന്‍ Interested in Posting
29 May, 2012
SharePoint 2010 - Cascading DropDown by using JavaScript 


Add the below JavaScript code to Newform/Editform :



br />  ar site;
 var context;
 var listItems;

br /> br /> unction FilterItem() {
br />  var listTitle = "Region-Site";
 //var selectedCnty = $("select[title='Country'] option:selected").val();

 //Get the current client context
 context = SP.ClientContext.get_current();
br />  var Listobj = context.get_web().get_lists().getByTitle(listTitle);

     // use a standard syntax CAML query to filter your results and the fields returned if required, by adding the following, or passing parameters to the load command below
ar query = new SP.CamlQuery();
br /> / You can leave out this line if you just want to return the entire list.
uery.set_viewXml(""+ selectedCountryID +"/Eq>/Query>);
br />  //var camlQuery = SP.CamlQuery.createAllItemsQuery();
br />  this.listItems = Listobj.getItems(query);
 //alert(listItems);
 context.load(listItems);
br />  context.executeQueryAsync(FilterItemSucceeded, ReadListItemFailed);

br /> // regular array (add an optional integer
br /> unction FilterItemSucceeded(sender, args) {
            var LstItemColl=new Array();
 var itemsString = '';
 var i =0;
 var enumerator = listItems.getEnumerator();
 //alert('test');
 while (enumerator.moveNext()) {
   var listItem = enumerator.get_current();
   var drpvalue;
   if(listItem.get_item('Region') == null)
   {
       drpvalue  = listItem.get_item('ID')+"#"+ listItem.get_item('Site');

   }else if( listItem.get_item('Site') == null)
   {
       drpvalue  = listItem.get_item('ID')+"#"+ listItem.get_item('Region');
   }else    
   {
       drpvalue = listItem.get_item('ID')+"#"+listItem.get_item('Region')+" - "+listItem.get_item('Site');
   }
   LstItemColl[i] = drpvalue;
   //alert(listItem.get_item('ID')+"#"+listItem.get_item('RegionSite'));
 
   //itemsString=listItem.get_item('Title') +'#' + listItem.get_item('Status');
   i++;
   //alert(itemsString);
   //itemsString += 'DocumentName : ' + listItem.get_item('Title') + ' ID : ' + listItem.get_id().toString() + ' Required : ' + listItem.get_item('Required') + '\n';
 }

 var optbox=getTagFromIdentifierAndTitle("SELECT","Region/Site","Region/Site");
    
     if(optbox!= null)
     {
/alert(selectedModel);
f(optbox.options.length == 1)

     for(var j=0; j      {
  ar mySplitResult1 = LstItemColl[j].toString().split("#");
  ptbox[optbox.options.length] = new Option(mySplitResult1[1], mySplitResult1[0], true, true);
    

ptbox.options[0].selected = true;
f(selectedModel != null)

or(var i=optbox.options.length-1; i>=0; i--)

f(optbox.options[i].text == selectedModel)

ptbox.options[i].selected = true;
('input[name=SPRegion/Site_Hidden]').val(optbox.options[i].value);





br /> ar optbox1=getTagFromIdentifierAndTitle("SELECT","Lookup","Region/Site");
     if(optbox1!= null)
     {
/alert(selectedModel);
f(optbox1.options.length == 1)

     for(var k=0; k      {
  ar mySplitResult1 = LstItemColl[k].toString().split("#");
  /alert(mySplitResult1[1]);
  ptbox1[optbox1.options.length] = new Option(mySplitResult1[1], mySplitResult1[0], true, true);
    

ptbox1.options[0].selected = true;
f(selectedModel != null)

or(var m=optbox1.options.length-1; m>=0; m--)

f(optbox1.options[m].text == selectedModel)

ptbox1.options[m].selected = true;
('input[name=SPRegion/Site_Hidden]').val(optbox1.options[i].value);






br /> unction ReadListItemFailed(sender, args) {
 alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

br /> / Find a contorl in the page by using title
unction getTagFromIdentifierAndTitle(tagName, identifier, title) {
br />    var len = identifier.length;
   var tags = document.getElementsByTagName(tagName);
br />    for (var i=0; i < tags.length; i++) {
       var tempString = tags[i].id;
       if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
           return tags[i];
       }
   }
   return null;


]]>

Posted By  dijin  08:04 hrs Comments(0)
29 May, 2012
SharePoint 2010 - Custom Validation in Newform/Editform by JavaScript 
Add the below JavaScript code to the page by using SharePoint Designer,


function PreSaveItem()
{
var RegionCnt = getTagFromIdentifierAndTitle("INPUT","TextField","Region");
var SiteCnt = getTagFromIdentifierAndTitle("INPUT","TextField","Site");
if( RegionCnt.value == "" && SiteCnt.value == "")
{
alert("You have to enter either Region or Site.");
return false;
}
else
{
return true;
}
}

// Find a contorl in the page by using title
function getTagFromIdentifierAndTitle(tagName, identifier, title) {

var len = identifier.length;
var tags = document.getElementsByTagName(tagName);

for (var i=0; i ‹ tags.length; i++) {
var tempString = tags[i].id;
if (tags[i].title == title && (identifier == "" || tempString.indexOf(identifier) == tempString.length - len)) {
return tags[i];
}
}
return null;
}


Posted By  dijin  08:04 hrs Comments(0)
29 May, 2012
SharePoint 2010 - JQuery Hide a Table Row in Newform/Editform/DisplayForm 



$(function() {
//$( ‘ td.ms-dttimeinput ‘ ).hide(); //hides the times on Start Time
$( ‘ span[title=All Day Event] › input ‘ ).attr("checked","checked"); // checks All Day Event
//hide all of the check-boxes I don?t need
$( ‘ tr:has(span[title=Recurrence]) ‘ ).not( ‘ tr:has(tr) ‘ ).hide();
$( ‘ tr:has(span[title=All Day Event]) ‘ ).not( ‘ tr:has(tr) ‘ ).hide();
$( ‘ tr:has(span[title=Workspace]) ‘ ).not( ‘ tr:has(tr) ‘ ).hide();
});
Posted By  dijin  08:04 hrs Comments(0)
29 May, 2012
SharePoint 2010 - Dynamic PDF Viewer by JavaScript 

Copy & Paste the below JavaScript function to Content Editor Webpart:




function getParameter(szName)
{
// Get value out of supplied parameter
var szUrl = window.location.search;
szUrl = szUrl.toLowerCase();
szName = szName.toLowerCase();
var szValue = "";
var nBegin = szUrl.indexOf(szName);
if (nBegin != -1)
{
szValue = szUrl.substring(nBegin + (szName.length + 1));
}
var nEnd = szValue.indexOf("&");
if (szValue != "" && nEnd != -1)
{
szValue = szValue.substring(0, nEnd);
}
return szValue;
}

function wmpCreate(url) {
var str = "";
var parampath = getParameter("TranPath");
var agt = navigator.userAgent.toLowerCase();
var is_ie = (agt.indexOf("msie") != -1);
if (is_ie) {
// create the WMP for IE
str = ‘
+ ‘ #toolbar=0&navpanes=0&scrollbar=1" width="1000" height="800"/ › ‘ ;
} else {
// create it for FF.
str = ‘
+ ‘ #toolbar=0&navpanes=0&scrollbar=1" width="1000" height="800"/ › ‘ ;
}

return str;
}
function pdfCreate() {
document.getElementById( ‘ pdffile ‘ ).innerHTML = wmpCreate();
}
_spBodyOnLoadFunctionNames.push("pdfCreate");
Posted By  dijin  08:04 hrs Comments(0)
29 May, 2012
SharePoint 2010 - Model Popup Window functionality in Quick Launch link 
Add the below JavaScript code in Master Page.


var optionsMobileDevice = {
allowMaximize: true,
showClose: true,
dialogReturnValueCallback: refreshCallback
};
function openModalWindow(URL) {
optionsMobileDevice.url = URL;
SP.UI.ModalDialog.showModalDialog(optionsMobileDevice);
}

function silentCallback(dialogResult, returnValue) {
}
function refreshCallback(dialogResult, returnValue) {
if(dialogResult == SP.UI.DialogResult.OK) {
var sourceURL = querySt( ‘ Source ‘ ,optionsMobileDevice.url);
window.location = sourceURL ;
}
}

function querySt(ji,pageURL) {
hu = pageURL;
gy = hu.split("&");
for (i=0;i
{
ft = gy[i].split("=");
if (ft[0] == ji) {
return ft[1];
}
}
}


Add the link in Quick Launch link :

java:openModalWindow( ‘ http://localhost/Lists/LstFileNumber/NewForm.aspx?IsDlg=1&Source=http://localhost/Lists/LstFileNumber/ ‘ );
Posted By  dijin  08:04 hrs Comments(0)
More >>
ABOUT ME
MY ARCHIVES
MY FAVORITE POSTS
MY SHARED POSTS
RECENT BLOGS
POPULAR BLOGS
STAFF BLOGS
EVENT BLOGS
CELEBRITY BLOGS
BRAND BLOGS
RECENT POSTS
DISCUSSED POSTS
BLOG CATEGORIES
Privacy | About Us |   Media Kit | Career@Manorama | Contact Us | Our Publications | Font | Sitemap | Feedback
© manoramaonline 2010