GetListItem:
Trong site hiên hành
<script type="text/javascript">
$(document).ready(function() {
try {
$().SPServices({
operation: "GetListItems",
//webURL: "http://192.168.1.216:8800",
async: false,
listName: "LoaiCongViec",
CAMLViewFields: "<ViewFields><FieldRef Name='Tiêu đề' /><FieldRef Name='Hạn xử lý' /></ViewFields>",
//CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + 2 + "</Value></Eq></Where></Query>",
//CAMLQueryOptions: "<QueryOptions><Folder>Lists/listname/foldername</Folder><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls><ViewAttributes Scope='RecursiveAll'/></QueryOptions>",
CAMLRowLimit: '4',
completefunc: function(xData, Status) {
alert(xData.responseXML.xml);
$(xData.responseXML).find("z\\:row").each(function() {
var liHtml = "<li>" + $(this).attr("ows_ID") + " " + $(this).attr("ows_Title") + " " + $(this).attr("ows_HanXuLy") + "</li>";
$("#tasksUL").append(liHtml);
});
}
});
}
catch (e) { alert(e); }
});
</script><ul id="tasksUL"/>
Từ Site khác trong cùng top level site
<script type="text/javascript">
$(document).ready(function() {
try {
$().SPServices({
operation: "GetListItems",
webURL: "http://192.168.1.216/Test",
async: false,
listName: "List",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Gender' /><FieldRef Name='Date' /></ViewFields>",
//CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + 2 + "</Value></Eq></Where></Query>",
//CAMLQueryOptions: "<QueryOptions><Folder>Lists/listname/foldername</Folder><IncludeAttachmentUrls>TRUE</IncludeAttachmentUrls><ViewAttributes Scope='RecursiveAll'/></QueryOptions>",
//CAMLRowLimit: '1',
completefunc: function(xData, Status) {
alert(xData.responseXML.xml);
$(xData.responseXML).find("z\\:row").each(function() {
var liHtml = "<li>" + $(this).attr("ows_ID") + " " + $(this).attr("ows_Title") +
" " + $(this).attr("ows_Gender") + " " +$(this).attr("ows_Date") + "</li>";
$("#tasksUL").append(liHtml);
});
} });
}
catch (e) { alert(e); }
}); </script>
<ul id="tasksUL"/>
UpdateListItemTác vụ thêm
<script type="text/javascript">
$(document).ready(function() {
var title="DAN";
var provinceName="Da Nang";
try {
$().SPServices({
operation: "UpdateListItems",
async: false,
listName: "ProvinceTest",
updates: "<Batch OnError='Continue'>" +
"<Method ID='1' Cmd='New'>" +
"<Field Name='Title'>" + title + "</Field>" +
"<Field Name='ProvinceName'>" + provinceName + "</Field>" +
"<Field Name='ID'></Field>" +
"</Method>" +
"</Batch>",
completefunc: function(xData, Status) {
alert(xData.responseXML.xml);
}
});
}
catch (e) { alert(e); }
});
</script>
UpdateListItemTác vụ sửa
<script type="text/javascript">
$(document).ready(function() {
try {
$().SPServices({
operation: "UpdateListItems",
listName: "HungTest",
ID: 1,
valuepairs: [["Title", "Học tập"]],
debug: true,
completefunc: null
});
}
catch (e) { alert(e); }
});
</script>
hiiii where this code apply in share point design can u explain detail with screen shots
ReplyDeleteHello,
ReplyDeleteSorry about late answer, Here is this code apply in share point design can u explain detail with screen shots
asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server"
style type="text/css"
Div.ms-titleareaframe {
height: 100%;
}
.ms-pagetitleareaframe table {
background: none;
}
style
script type="text/javascript"
alert('Here is this code apply in share point design can u explain detail with screen shots');
script
asp:Content