tabalinas/jsgrid
View on GitHubJsGrid controller. How to Update Items that are inserted to Sharepoint List?
Open
#992 opened on Jan 6, 2018
help wanted
Description
Here is my code//
controller:{
insertItem: function(item) {
$.ajax
({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('POTable')/items",
type: "POST",
data: JSON.stringify
({
__metadata:
{
type: "SP.Data.POTableListItem"
},
HrmsRefNo:item.HRMSRef,
PONumber:item.PONo,
PODate:item.PODate,
EmpNo:item.EmpNo,
Amount:item.Amount,
Currency:item.Cur,
AmountSAR:item.AmountSAR,
}),
headers:
{
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "POST"
},
success: function(data,status,xhr)
{
// retriveListItem();
console.log(data.d.Id);
var id=data.d.Id;
},
error: function(xhr, status, error)
{
// $("#ResultDiv").empty().text(data.responseJSON.error);
alert("error:"+data.responseJSON.error);
}
});
return item;
},
updateItem: function(item) {
var PassId=function(id){
jQuery.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getByTitle('POTable')/items",
type: "POST",
data: JSON.stringify({
"__metadata": { type: "SP.Data.POTableListItem" },
HrmsRefNo:item.HRMSRef,
PONumber:item.PONo,
PODate:item.PODate,
EmpNo:item.EmpNo,
Amount:item.Amount,
Currency:item.Cur,
AmountSAR:item.AmountSAR,
}),
headers: {
Accept: "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val(),
"IF-MATCH": item.__metadata.etag,
"X-Http-Method": "MERGE"
},
success: function (data) {
alert("success");
},
error: function (err) {
alert("error");
}
});
}
return item;
},
}//controller close
1.I am using sharepoint as my document storage. I did with insertItem controller ,its working perfectly. But I am not able to update the item again using updateItem controller.
3.My question is how can I update items , or do I need to get the unique id of a particular list item in sharepoint to update the value through js grid. 4. What is the problem with my code which doesn't work for updateItem controller.
5.I also require to use deleteItem controller.So Explain deleteItem controller too, whether it also require unique Id to delete.
5.Please help me regarding this with the required code snippet.
Thanks in advance.