Saturday, November 13, 2010

Script to hide Edit, delete item properties of sharepoint list

hideFormMenuItems("New Item", "Delete Item");





function hideFormMenuItems()

{





var titleToHide="";

var anchorTag;

var allAnchorTags = document.getElementsByTagName

('a');

for(var i = 0; i <

hideFormMenuItems.arguments.length; i++ )

{

titleToHide =

hideFormMenuItems.arguments[i];

if(titleToHide!='Alert Me')

{



for (var j = 0; j

< allAnchorTags.length; j++)

{



anchorTag= allAnchorTags[j];





if (anchorTag.title.indexOf(titleToHide)!=-1)



{













anchorTag.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="no

ne";





anchorTag.parentNode.parentNode.parentNode.parentNode.parentNode.nextSibling.style

.display="none";



break;



}



}

}

else

{

for (var k=0; k <

allAnchorTags.length;k++)

{



anchorTag= allAnchorTags[k];







if (anchorTag.id.indexOf("SubscribeButton")!=-1)



{





anchorTag.parentNode.parentNode.parentNode.parentNode.parentNode.style.display="no

ne";



break;





//anchorTag.parentNode.parentNode.parentNode.parentNode.parentNode.previousSibling

.style.display="none";





}

}



}





}



var allSpanTags = document.getElementsByTagName

("span");

var spanTag;

var toolbarRow;

var lastCell;

for(var m=0; m < allSpanTags.length;m++)

{

spanTag = allSpanTags[m];



if

(spanTag.id=='part1')

{



toolbarRow = spanTag.childNodes[2].firstChild.firstChild;



lastCell = toolbarRow.lastChild.previousSibling





while(lastCell.style.display=='none')

{











lastCell = lastCell.previousSibling;





}





if(lastCell.innerText == '|')

{







lastCell.style.display='none';



}

















break;

}

}





}



Script to keep the group  by items in collapsed mode

<script type="text/javascript">
var rows = document.getElementsByTagName('tr');
var numRows = rows.length;
for (var i = 0; i < numRows; ++i)
{
    if (rows[i].getAttribute("isexp") != null && rows[i].getAttribute("isexp").toLowerCase() == "true")
    {
          if(rows[i].firstChild.firstChild != null && rows[i].firstChild.firstChild.tagName.toLowerCase() == "a")
          {   
              if (rows[i].firstChild.firstChild.title.toLowerCase() == "expand/collapse")
                  {
                    rows[i].firstChild.firstChild.fireEvent("onclick");
            }
          }
    }

}
</script>

No comments:


A sales engineer is someone who promise you a bridge, even when there's no river.