Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ The config object may contain following options (default values are specified be
confirmDeleting: true,
deleteConfirm: "Are you sure?",

confirmationPopupProvider: null,

pagerContainer: null,
pageIndex: 1,
pageSize: 20,
Expand Down Expand Up @@ -341,6 +343,28 @@ A boolean value specifying whether to ask user to confirm item deletion.
A string or a function returning string specifying delete confirmation message to be displayed to the user.
A function has the signature `function(item)` and accepts item to be deleted.

### confirmationPopupProvider (default `null`)
A function handling confirmation request. Accepts two arguments: message and action callback.
Example:

```javascript

$("#grid").jsGrid({
...

confirmationPopupProvider: function (message, callback) {
if (window.confirm(message)) {
if (window.confirm('Are you really sure?')) {
callback();
}
}
},

...
});

```

### pagerContainer (default `null`)
A jQueryElement or DomNode to specify where to render a pager. Used for external pager rendering. When it is equal to `null`, the pager is rendered at the bottom of the grid.

Expand Down
20 changes: 18 additions & 2 deletions src/jsgrid.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
confirmDeleting: true,
deleteConfirm: "Are you sure?",

confirmationPopupProvider: null,

selecting: true,
selectedRowClass: "jsgrid-selected-row",
oddRowClass: "jsgrid-row",
Expand Down Expand Up @@ -1314,8 +1316,22 @@
if(!$row.length)
return;

if(this.confirmDeleting && !window.confirm(getOrApply(this.deleteConfirm, this, $row.data(JSGRID_ROW_DATA_KEY))))
return;
if (this.confirmDeleting) {
var message = getOrApply(this.deleteConfirm, this, $row.data(JSGRID_ROW_DATA_KEY));
var self = this;

if (this.confirmationPopupProvider) {
this.confirmationPopupProvider(message, function () {
self._deleteRow($row);
});

return;
} else {
if (!window.confirm(message)) {
return;
}
}
}

return this._deleteRow($row);
},
Expand Down