Sunday, 21 February 2016

Create a DashBoard Using XSLT with Statuswise Count to Assignee

<Xsl>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
             exclude-result-prefixes="msxsl" xmlns:ddwrt2="urn:frontpage:internal">

<xsl:output method='html' indent='yes'/>
<xsl:key name="Grouping" match="Row" use="@AssignedTo.id" />

<xsl:template match='dsQueryResponse' xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">


<table id="tbl1" cellpadding="10" cellspacing="0" border="0" style="padding:0px;" class="tableRound">
<xsl:apply-templates select='Rows/Row'/>
</table>
</xsl:template>
<xsl:template match='/' xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:ghost="" xmlns:ddwrt2="urn:frontpage:internal">
<tr>
<td style="font-weight:bold; color:#002276">Assign To</td>
<td style="font-weight:bold; color:#002276">Completed</td>
<td style="font-weight:bold; color:#002276">In Progress</td>
<td style="font-weight:bold; color:#002276">Not Started</td>
<td style="font-weight:bold; color:#002276">Waiting on someone else</td>
</tr>

<xsl:for-each select="/dsQueryResponse/Rows/Row[generate-id(.)=generate-id(key('Grouping',@AssignedTo.id))]/@AssignedTo.id">
<xsl:sort />

<tr>

<td width="58%"><xsl:value-of select="key('Grouping',.)/@AssignedTo" disable-output-escaping="yes" /></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='Completed'])" disable-output-escaping="yes"></xsl:value-of></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='In Progress'])" disable-output-escaping="yes"></xsl:value-of></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='Not Started'])" disable-output-escaping="yes"></xsl:value-of></td>
<td width="10%"><xsl:value-of select="count(key('Grouping',.)[@Status='Waiting on someone else'])" disable-output-escaping="yes"></xsl:value-of></td>



</tr>

</xsl:for-each>  

</xsl:template>
</xsl:stylesheet></Xsl>

Open and Close A Model Popup in sharepoint

For Open A PoPUp
<a href="javascript:SP.UI.ModalDialog.ShowPopupDialog('/sitPages.aspx', null, 500, 300);" >
Edit
 </a>

javascript:SP.UI.ModalDialog.ShowPopupDialog('PAgeAddress.aspx?ID={$thisNode/@TRFId}', null, 1000, 800);

javascript:OpenPopUpPageWithTitle('/SitePages/LeaderMessage.aspx',null,null,null,'Leader Message');


and Close A PoPUp from code behinde

public void CloseForm()
        {
            HttpContext context = HttpContext.Current;
            if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
            {
                context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup()</script>");
                context.Response.Flush();    
                context.Response.End();
            }
        }

Saturday, 20 February 2016

left quick bar menubar styles


.s4-ql UL.root > LI > .menu-item {

PADDING-BOTTOM: 2px;
BORDER-RIGHT-WIDTH: 0px;
OVERFLOW-X: hidden;
TEXT-TRANSFORM: capitalize;
MARGIN: 0px; MIN-HEIGHT: 19px;
 PADDING-LEFT: 10px;
 PADDING-RIGHT: 4px;
 FONT-FAMILY: Arial, Helvetica, sans-serif;
  WORD-WRAP: break-word;
   BORDER-TOP-WIDTH: 0px;
    COLOR:white;
    FONT-SIZE: 12px;
    font-weight: normal;
     BORDER-LEFT-WIDTH: 0px;
     PADDING-TOP: 8px;
        background-color:#3c8a2e;
        border-bottom:1px white solid;
}
.s4-ql UL.root > LI > .menu-item:hover{
background:#cee2cb;
color:#000;
}

BODY #s4-leftpanel {
MARGIN-TOP: 25px;
WIDTH: 150px;
 FLOAT: left;
  MARGIN-LEFT: 5px;
  border-bottom:1px #002776 dotted;
}
BODY #s4-leftpanel-content {
border:none;
}
.s4-ql UL.root UL > LI > A{
 border-bottom:1px dotted;
border-bottom-color:black;

}



How to set multiUserValueCollection in SPFieldUserValueCollection




public SPFieldUserValue ConvertLoginAccount(string userid)
        {
            SPFieldUserValue uservalue;
            using (SPSite site = new SPSite(SPContext.Current.Web.Url))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPUser requireduser = web.EnsureUser(userid);
                    uservalue = new SPFieldUserValue(web, requireduser.ID, requireduser.LoginName);
                }
            }
            return uservalue;
        }


//user collection in array
string[] userarray = lblFunctionTeam.Text.ToString().Split(';');

                                SPFieldUserValueCollection usercollection = new SPFieldUserValueCollection();
                                for (int i = 0; i < userarray.Length - 1; i++)
                                {
                                    SPFieldUserValue usertoadd = ConvertLoginAccount(userarray[i]);
                                    usercollection.Add(usertoadd);
                                }
                  //set multiuserCollection
                                item["UserCollectionField"] = usercollection;
//single user Value
  SPFieldUserValue usertoadd1= ConvertLoginAccount("userIdentityEmailOrLoginName");
    item["UserField"] =usertoadd1;

how to get user's name ,emaiid ,loginid and id from SPFieldUserValueCollection

  SPFieldUserValueCollection userFieldValueCollectionfunction =new  SPFieldUserValueCollection(web,convert.tostring(item[UserCollectionCoulmnName]));

                            foreach (SPFieldUserValue userFieldValuefunctin in userFieldValueCollectionfunction)
                            {
                                console.writeline( userFieldValuefunctin.User.Name);
                                console.writeline( userFieldValuefunctin.User.Email);
                            }

hide complete ribbon in dialog box using jquery

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script type="text/javascript">

_spBodyOnLoadFunctionNames.push("hideItAll");

function hideItAll(){
 if(window.location.search.toLowerCase().indexOf("isdlg=1") > 0){
 $("#s4-ribbonrow").hide(); //ribbon bar
 }
}
</script>

hide cancel button in ribbon Sharepoint listItem form



<script type="text/javascript">
var elem = document.getElementById("Ribbon.DocLibListForm.Edit.Commit.Cancel-Large");
elem.style.display = "none";
setInterval(abc,3000);
function abc()
{
var x=document.getElementsByTagName("input");

for (var i=0; i < x.length; i++)
{
if (x.item(i).type=="button" && x.item(i).value=="Cancel")
{

x.item(i).style.display="none";
}
}
}

</script>

Header with Search textbox in ListView Webpart using Jquery

<script src="http://www.google.com/jsapi"></script>

<script>


google.load("jquery", "1.2.6");

google.setOnLoadCallback(function() {

$(document).ready(function()
{
jQuery.extend(jQuery.expr[':'], {
 containsIgnoreCase: "(a.textContent||a.innerText||jQuery(a).text()||'').toLowerCase().indexOf((m[3]||'').toLowerCase())>=0"
});


$("table.ms-listviewtable tr.ms-viewheadertr").each(function()
{
if($("td.ms-vh-group", this).size() > 0)
{
return;
}

var tdset = "";

var colIndex = 0;

$(this).children("th,td").each(function()
{
if($(this).hasClass("ms-vh-icon"))
{
// attachment
tdset += "<td></td>";
}
else
{
// filterable
tdset += "<td><input type='text' class='vossers-filterfield' filtercolindex='" + colIndex + "' /></td>";
}

colIndex++;
});

var tr = "<tr class='vossers-filterrow'>" + tdset + "</tr>";

$(tr).insertAfter(this);
});


$("input.vossers-filterfield")
.css("border", "1px solid #7f9db9")
.css("width", "100%")
.css("margin", "2px")
.css("padding", "2px")
.keyup(function()
{
var inputClosure = this;

if(window.VossersFilterTimeoutHandle)
{
clearTimeout(window.VossersFilterTimeoutHandle);
}

window.VossersFilterTimeoutHandle = setTimeout(function()
{
var filterValues = new Array();

$("input.vossers-filterfield", $(inputClosure).parents("tr:first")).each(function()
{
if($(this).val() != "")
{
filterValues[$(this).attr("filtercolindex")] = $(this).val();
}
});


$(inputClosure).parents("tr.vossers-filterrow").nextAll("tr").each(function()
{
var mismatch = false;

$(this).children("td").each(function(colIndex)
{
if(mismatch) return;

if(filterValues[colIndex])
{
var val = filterValues[colIndex];

// replace double quote character with 2 instances of itself
val = val.replace(/"/g, String.fromCharCode(34) + String.fromCharCode(34));

if($(this).is(":not(:containsIgnoreCase('" + val + "'))"))
{
mismatch = true;
}
}
});

if(mismatch)
{
$(this).hide();
}
else
{
$(this).show();
}
});

}, 250);
});
});

});

</script>

Find CheckOut files In SPLibrary or Folder in sharepoint programatically


        public static void GetCheckOutfile(SPDocumentLibrary docs)
        {
          //  foreach (SPCheckedOutFile spFiles in spFolder.Files)



            foreach (SPCheckedOutFile file in docs.CheckedOutFiles)
            {

                if (file.LeafName != file.Url.ToString().Split('/')[3])
                {
                 

                 
                         
                       console.writeLine( file.LeafName);
                 
                  }


            }




}

Hide link in ECB Menu

function HideFeatureActivatedECBMenuItem() {
    if (!CanExecuteHideForECBMenuItem()) return;

    /* find the ECB menu items which are added via feature activation */
    var ecbId = "ECBItems";
    var listName;
    if ((null != ctx.listName) && (0 < ctx.listName.length)) {
        listName = ctx.listName.toLowerCase();
        ecbId = ecbId + "_" + listName;
    }
    var elemTBody = document.getElementById(ecbId);
    if (elemTBody != null) {
        // iterate each table row to find the ECB menu item to remove (hide)
        for (var iMenuItem = 0; iMenuItem < elemTBody.childNodes.length; iMenuItem++)
 {
            var elemTr = elemTBody.childNodes[iMenuItem];
            var elemTdTitle = elemTr.childNodes[0];
            var title = GetInnerText(elemTdTitle);

            // check the ECB item title
            if (title === "Edit Item")
 {
                elemTBody.removeChild(elemTr);
 }
        }
    }
}