Note:-
From Internet You have to
Download the below said Things.
- Latest JQuery File.
- Latest SPAPI_Core.JS File.
- Latest SPAPI_Lists.JS File.
- I had tested this code in FireFox, Chrome & Safari Browsers.
Aspx
|
<%@ Page
masterpagefile="~masterurl/default.master" language="C#"
inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,
Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document"
meta:webpartpageexpansion="full" %>
<asp:Content
id="Content1" runat="Server"
contentplaceholderid="PlaceHolderMain">
<script
type="text/javascript"
src="/UserPages/JS/jquery.min.1.8.3.js"></script>
<style
type="text/css">
.HeadingClass
{
font-size:13px;
background-color:blue;
color:white;
font-weight:bold;
}
.LoopRecordsClass
{
font-size:13px;
background-color:Green;
color:white;
}
.LoopRecordsClass a
{
text-decoration:none;
font-size:13px;
color:white;
}
.LoopRecordsClass
a:hover
{
text-decoration:underline;
font-size:13px;
color:white;
}
.LoopRecordsClass a:after
{
text-deocration:none;
font-size:13px;
color:white;
}
</style>
<script
type="text/javascript"
src="/UserPages/JS/SPAPI_Core.js"></script>
<script
type="text/javascript"
src="/UserPages/JS/SPAPI_Lists.js"></script>
<script
type="text/javascript"
src="/UserPages/JS/JWS_Practice.JS"></script>
<table width="100%"
cellpadding="0" cellspacing="0">
<tr>
<td>
<table
cellpadding="0" cellspacing="0"
width="100%">
<tr>
<td
id="tdJWSPractice"
style="padding-left:20px;"></td>
</tr>
</table>
</td>
</tr>
</table>
</asp:Content>
|
JS
|
var strSiteUrl="http://SPSERVER:100/";
var objList=new
SPAPI_Lists(strSiteUrl);
var strHTML="";
function GetIems()
{
var
sQuery="<Query><OrderBy><FieldRef Name='Modified'
Ascending='False' /></OrderBy></Query>";
var
strViewFields="<ViewFields><FieldRef Name='Title'
/><FieldRef Name='ID' /><FieldRef Name='Country'
/><FieldRef Name='Gender' /></ViewFields>";
/*
Note:-
Here
Title is Single Lines Of Text.
Here
Country is Lookup Field.
Here
Gender is Choice Field.
*/
var
result =
objList.getListItems("JWS
Practice","",sQuery,strViewFields,"","","");
strHTML+="<Table
width='100%' cellpadding'0' cellspacing='0'>";
var
strRows="";
var
ItemRows='';
if
($.browser.webkit)
{
ItemRows="row";
}
else
{
ItemRows="z\\:row";
}
if($(result.responseXML).find(ItemRows).length>0)
{
strHTML+="<Tr>";
strHTML+="<Td
Class='HeadingClass'>";
strHTML+="Title";
strHTML+="</Td>";
strHTML+="<Td
Class='HeadingClass'>";
strHTML+="Country";
strHTML+="</Td>";
strHTML+="<Td
Class='HeadingClass'>";
strHTML+="Gender";
strHTML+="</Td>";
strHTML+="</Tr>";
$(result.responseXML).find(ItemRows).each(function()
{
strHTML+="<Tr>";
strHTML+="<Td
Class='LoopRecordsClass'>";
strHTML+=$(this).attr('ows_Title');
strHTML+="</Td>";
strHTML+="<Td
Class='LoopRecordsClass'>";
strHTML+=$(this).attr('ows_Country').split("#")[1];
strHTML+="</Td>";
strHTML+="<Td
Class='LoopRecordsClass'>";
strHTML+=$(this).attr('ows_Gender');
strHTML+="</Td>";
strHTML+="</Tr>";
});
}
else
{
strHTML+="<Tr>";
strHTML+="<Td>";
strHTML+="No
Records Available";
strHTML+="</Td>";
strHTML+="</Tr>";
}
strHTML+="</Table>";
$("#tdJWSPractice").html(strHTML);
}
_spBodyOnLoadFunctionNames.push("GetIems");
|
No comments:
Post a Comment