Skip to content

Commit 43f1069

Browse files
authored
Merge pull request #3 from SyncfusionExamples/demo
Added delete functionality review changes.
2 parents f2169f8 + 36ce563 commit 43f1069

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

ASP.NET Core/Views/Home/Documenteditor.cshtml

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ var grid = new ej.grids.Grid({
8989
});
9090
9191
grid.appendTo('#Grid');
92-
92+
var fileName= '';
93+
var userName = '';
9394
function rowSelected(args) {
94-
fileName =args.data.DocumentName;
95+
fileName = args.data.DocumentName;
96+
userName = args.data.AuthorName;
9597
}
9698
// Initialize Dialog component
9799
var editorPopup = new ej.popups.Dialog({
@@ -172,7 +174,7 @@ function onOpen(args) {
172174
// setting maxHeight to the Dialog.
173175
args.maxHeight = '600px';
174176
}
175-
var fileName= '';
177+
176178
function onClose(){
177179
makeHTTPRequest("LogOut");
178180
refresh();
@@ -191,8 +193,24 @@ function openDocumentEditor(){
191193
}
192194
193195
function deleteRecords(){
194-
makeHTTPRequest("DeleteRecords");
195-
refresh();
196+
if(userName == "") {
197+
selectionAlertDialog();
198+
}
199+
else if(userName == "@ViewBag.userName"){
200+
makeHTTPRequest("DeleteRecords");
201+
refresh();
202+
}
203+
else {
204+
ej.popups.DialogUtility.alert({
205+
title: 'Can\'t delete this document',
206+
content: "You are not allowed to delete the other user-created document.",
207+
okButton: { text: 'OK' },
208+
isModal: true,
209+
showCloseIcon: true,
210+
closeOnEscape: true,
211+
animationSettings: { effect: 'Zoom' }
212+
})
213+
}
196214
}
197215
function refresh(){
198216
location.reload();
@@ -253,7 +271,15 @@ function createNewDocument(){
253271
}
254272
document.getElementById('edit').addEventListener('click', () => {
255273
if (fileName == "") {
256-
ej.popups.DialogUtility.alert({
274+
selectionAlertDialog();
275+
}
276+
else {
277+
ImportDocument();
278+
}
279+
280+
});
281+
function selectionAlertDialog() {
282+
ej.popups.DialogUtility.alert({
257283
title: 'Alert',
258284
content: "Please select the document",
259285
okButton: { text: 'OK' },
@@ -262,12 +288,7 @@ document.getElementById('edit').addEventListener('click', () => {
262288
closeOnEscape: true,
263289
animationSettings: { effect: 'Zoom' }
264290
})
265-
}
266-
else {
267-
ImportDocument();
268-
}
269-
270-
});
291+
}
271292
function ImportDocument(){
272293
var http = new XMLHttpRequest();
273294
http.open('POST', '/api/documenteditor/ImportFile');

0 commit comments

Comments
 (0)