Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147611 | Sep 17,2019 12:28 PM UTC | Sep 20,2019 10:48 AM UTC | ASP.NET Core - EJ 2 | 6 |
![]() |
Tags: DataGrid |
...
@{
List<object> commands = new List<object>();
commands.Add(new { type = "Delete", buttonOption = new { content = "Delete", cssClass = "e-flat e-details" } });
}
<ejs-grid id="Grid" allowPaging="true" load="onLoad" toolbar="@( new List<object>() {"Add","Edit","Delete","Update","Cancel"})" dataBound="dataBound">
<e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Dialog" showDeleteConfirmDialog="true" showConfirmDialog="true"></e-grid-editSettings>
<e-data-manager url="/Index?handler=DataSource" insertUrl="/Index?handler=Insert" updateUrl="/Index?handler=Update" removeUrl="/Index?handler=Delete" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-pageSettings pageCount="5" pageSize="5"></e-grid-pageSettings>
<e-grid-columns>
...
<e-grid-column headerText="Manage Records" width="120" commands="commands"></e-grid-column>
</e-grid-columns>
</ejs-grid>
...
<script>
function dataBound(args) {
this.editModule.dialogObj.beforeOpen = function (args) {
var prod = this.targetEle.ej2_instances[0].getSelectedRecords()[0].OrderID; //get the corresponding row OrderID
this.targetEle.ej2_instances[0].localeObj.currentLocale.ConfirmDelete = "Do you really want to delete the product " + prod + " ?"; //change the default delete dialog message in locale object
this.content = "<div>" + "Do you really want to delete the product " + prod + " ?" + "</div>"; //change the default delete dialog message
}
}
</script> |
...
@{
List<object> commands = new List<object>();
commands.Add(new { type = "Restore", buttonOption = new { content = "Restore", cssClass = "e-flat e-details" } }); // custom
}
<div id="dialog"></div>
<ejs-grid id="Grid" allowPaging="true" load="onLoad" toolbar="@( new List<object>() {"Add","Edit","Delete","Update","Cancel"})" commandClick="commandClick" dataBound="dataBound">
<e-grid-columns>
...
</e-grid-columns>
</ejs-grid>
<script>
function dataBound(args) {
this.editModule.dialogObj.beforeOpen = function (args) {
var prod = this.targetEle.ej2_instances[0].getSelectedRecords()[0].OrderID;
this.targetEle.ej2_instances[0].localeObj.currentLocale.ConfirmDelete = "Do you really want to delete the product " + prod + " ?";
this.content = "<div>" + "Do you really want to delete the product " + prod + " ?" + "</div>";
}
var dialog = new ej.popups.Dialog({
// Enables the footer buttons
buttons: [
{
// Click the footer buttons to hide the Dialog
'click': (e) => {
dialog.hide();
},
// Accessing button component properties by buttonModel property
buttonModel: {
//Enables the primary button
isPrimary: true,
content: 'OK'
}
},
{
'click': () => {
dialog.hide();
},
buttonModel: {
content: 'Cancel'
}
}
],
target: document.getElementById("Grid"),
// Dialog width
width: '450px',
visible: false
});
dialog.appendTo('#dialog');
}
function commandClick(args) {
if (args.commandColumn.type == "Restore")
document.getElementById("dialog").ej2_instances[0].content = "Do you really want to restore the product " + args.rowData.OrderID + " ?"; //assigning dialog text
document.getElementById("dialog").ej2_instances[0].visible = true;
}
</script> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.