카테고리 없음
[자바 스크립트] 사용자 지정 페이지에서 목록 항목을 삭제하는 방법은 무엇입니까?
행복을전해요
2021. 2. 1. 08:48
Microsoft에서 제공하는 기능은 다음과 같습니다.
function DeleteListItem() {
ULSrLq: ;
if (!IsContextSet()) return;
var b = currentCtx,
e = currentItemID,
g = currentItemFSObjType,
c = L_STSRecycleConfirm_Text;
if (!b.RecycleBinEnabled || b.ExternalDataList) c = L_STSDelConfirm_Text;
if (b.HasRelatedCascadeLists && b.CascadeDeleteWarningMessage != null) c = b.CascadeDeleteWarningMessage + c;
if (confirm(c)) {
var h = L_Notification_Delete,
f = addNotification(h, true),
a = b.clvp;
if (b.ExternalDataList && a != null) {
a.DeleteItemCore(e, g, false);
a.pendingItems = [];
a.cctx.executeQueryAsync(function () {
ULSrLq: ;
if (typeof a.rgehs != "undefined") {
if (a.rgehs.length == 1 && a.rgehs[0].get_serverErrorCode() == SP.ClientErrorCodes.redirect) {
GoToPage(a.rgehs[0].get_serverErrorValue());
return
}
removeNotification(f);
a.ShowErrorDialog(RefreshOnDialogClose)
} else RefreshPage(SP.UI.DialogResult.OK)
}, function () {
ULSrLq: ;
removeNotification(f);
typeof a.rgehs != "undefined" && a.ShowErrorDialog()
})
} else {
var d = b.HttpPath + "&Cmd=Delete&List=" + b.listName + "&ID=" + e + "&NextUsing=" + GetSource();
if (null != currentItemContentTypeId) d += "&ContentTypeId=" + currentItemContentTypeId;
SubmitFormPost(d)
}
}
}
이를 통해 귀하의 케이스에 필요한 것을 찾을 수 있습니다.
페이지에서 일부 jQuery / JavaScript를 사용하는 경우 유용한 기능 (목록에서 데이터 가져 오기 또는 항목 삭제 등)을 제공하는 SharepointPlus 를 확인할 수도 있습니다 .
-------------------나는 그것을 알아!
SharePoint Services에서 가져온 "SPAPI_Lists"라는 JS 라이브러리가 있습니다.
라는 기능을 제공합니다 quickDeleteListItem(listName, listItemId)
.
코드는 다음과 같습니다.
var urlThatContainsList = 'http://www.samplesite.com/sample';
var listName = 'Sample List';
var listItemId = 3;
new SPAPI_Lists(urlThatContainsList).quickDeleteListItem(listName, listItemId);
출처
https://stackoverflow.com/questions/22049826