Get List Items Using SPServices
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Listname",
CAMLQuery: "<Query><Where><IsNotNull><FieldRef Name='Phase' /></IsNotNull></Where> <GroupBy Collapse='True'><FieldRef Name='Phase'></FieldRef></GroupBy> </Query>";
CAMLViewFields: ""<ViewFields><FieldRef Name='ID' /><FieldRef Name='Phase' /><FieldRef Name='DueDate' />",
completefunc: function (xData, Status)
{
if (Status == "success")
{
$(xData.responseXML).SPFilterNode("z:row").each(function()
{
var Phase = $(this).attr("ows_Phase");
var DueDate = $(this).attr("ows_DueDate");
});
}
}
});
Delete All Items from List
function DeleteAllItemsFromList()
{
$.SPServices.SPUpdateMultipleListItems({
listName: "Listname",
CAMLQuery: "<Query><Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where></Query>",
batchCmd: "Delete"});
}
Add Item to List
$.SPServices({
operation: 'UpdateListItems',
listName: "Listname",
updates: '<Batch OnError="Continue">' +
'<Method ID="1" Cmd="Update">' +
'<Field Name="ID">'+ ItemID +'</Field>' +
'<Field Name="Title">'+ title +'</Field>' +
'</Method>' +
'</Batch>',
completefunc: function(xData, Status)
{}
});
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Listname",
CAMLQuery: "<Query><Where><IsNotNull><FieldRef Name='Phase' /></IsNotNull></Where> <GroupBy Collapse='True'><FieldRef Name='Phase'></FieldRef></GroupBy> </Query>";
CAMLViewFields: ""<ViewFields><FieldRef Name='ID' /><FieldRef Name='Phase' /><FieldRef Name='DueDate' />",
completefunc: function (xData, Status)
{
if (Status == "success")
{
$(xData.responseXML).SPFilterNode("z:row").each(function()
{
var Phase = $(this).attr("ows_Phase");
var DueDate = $(this).attr("ows_DueDate");
});
}
}
});
Delete All Items from List
function DeleteAllItemsFromList()
{
$.SPServices.SPUpdateMultipleListItems({
listName: "Listname",
CAMLQuery: "<Query><Where><IsNotNull><FieldRef Name='Title' /></IsNotNull></Where></Query>",
batchCmd: "Delete"});
}
Add Item to List
$.SPServices({
operation: 'UpdateListItems',
listName: "Listname",
updates: '<Batch OnError="Continue">' +
'<Method ID="1" Cmd="Update">' +
'<Field Name="ID">'+ ItemID +'</Field>' +
'<Field Name="Title">'+ title +'</Field>' +
'</Method>' +
'</Batch>',
completefunc: function(xData, Status)
{}
});
No comments:
Post a Comment