-This script is designed/tested only on Display form of list item.
-Add your attachment field under a div using SP designer, <div id="divAttachment"> <SharePoint:AttachmentsField ControlMode="Display" FieldName="Attachments" runat="server" Visible="true"/></div>
-Add below script on the page
<script language="javascript">
var fullHtml = $('#idAttachmentsTable').html();
var fileName = new Array();
var i = 0;
$("#idAttachmentsTable").find('a').each(function() {
fileName[i] = new Array();
fileName[i][0]= $(this).text();
fileName[i][1] = $(this).attr('href');
i++;
});
fileName.sort();
document.getElementById('divAttachment').innerHTML = '';
for(var cntArr=0; cntArr<fileName.length;cntArr++)
{
var strHref = "<a href='"+fileName[cntArr][1]+"'>"+fileName[cntArr][0]+"</a><br/>";
document.getElementById('divAttachment').innerHTML += strHref;
}
</script>
-Add your attachment field under a div using SP designer, <div id="divAttachment"> <SharePoint:AttachmentsField ControlMode="Display" FieldName="Attachments" runat="server" Visible="true"/></div>
-Add below script on the page
<script language="javascript">
var fullHtml = $('#idAttachmentsTable').html();
var fileName = new Array();
var i = 0;
$("#idAttachmentsTable").find('a').each(function() {
fileName[i] = new Array();
fileName[i][0]= $(this).text();
fileName[i][1] = $(this).attr('href');
i++;
});
fileName.sort();
document.getElementById('divAttachment').innerHTML = '';
for(var cntArr=0; cntArr<fileName.length;cntArr++)
{
var strHref = "<a href='"+fileName[cntArr][1]+"'>"+fileName[cntArr][0]+"</a><br/>";
document.getElementById('divAttachment').innerHTML += strHref;
}
</script>
No comments:
Post a Comment