BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
Hi Kivito,
Thanks for using Syncfusion products.
Query 1: How to restore deleted items from grid if save operation wasn't successful
We understood that you are using “batch” editing and call the “batchSave” method to save the changes after delete operation.
We can restore the deleted items, when save operation is uncomplete using “batchCancel” method which will cancel the modified changes in Grid control when edit mode is “batch”.
Please refer to the Help document for “batchCancel” method.
http://help.syncfusion.com/js/api/ejgrid#methods:batchcancel
Query 2: How to return to the same page from where delete request was called
We are unable to reproduce the issue and provide below details,
1. Code example used for delete records and auto save it.
2. Details of editSettings used and Grid rendering code.
The provided information will help to analyze the issue and provide you the response as early as possible.
Regards,
Gowthami V.
Try the given suggestion and prepare a sample at your end.
Please get back to us if you need further assistance.
Regards,
Gowthami V.
While navigating the screens, the widgets are rendered without removing old widgets. It’s a light switch default behavior.
To resolve the issue we have removed the old widget (Removed grid) using below code example,
myapp.TimeDivisionsGridEditingTemplate.TimeDivision_render = function (element, contentItem) { // Write code here. $(document.getElementById("Artikal")).remove(); var itemTemplate = $("<div style='margin-right:15px'></div>").attr('id', 'Artikal') . . . . // Append the div element to screen } |
The grid will render with the screen data initially loaded from visual collection(contentItem.value.data) and paging will be applied to that data.
Query 3: try to go on ie. page 3, delete one item from the list and press save (on grid toolbar), it will save the grid but paging will jump on page 1, not stay on page 3.
As in your code example we have tried and for deleting you have used user defined method “deleteSelected” and could not find the definition for that method.
Please provide code example that you have used for delete the records (deleteSelected method) and the provided information will help to analyze the issue and provide you the response as early as possible.
Query 4: I have requirement that should fit for batch edit mode
We can achieve your requirement “need to implement save on page change” by calling the “batchSave” method in “actionComplete” event of the grid as follows,
. . . . . . . .
itemTemplate.ejGrid( if (args.requestType == "paging") this.batchSave(); }); } |
itemTemplate.ejGrid( }); } |
itemTemplate.ejGrid( toolbarClick: function (args) { case "Delete": contentItem.value.selectedItem = this.getSelectedRecords()[0]; var currentPage = this.model.pageSettings.currentPage; if (!($.isEmptyObject(contentItem.value.selectedItem))) { args.cancel = true; contentItem.value.deleteSelected(); //delete the records in grid myapp.commitChanges().then(function success() { // If success. var grid = $(".e-grid").data("ejGrid"); grid.gotoPage(currentPage); msls.showMessageBox("Delete is successfull.", { title: "Delete" }); } } }); |
4. Now in the grid, to display the CustomerID (Naziv) field from Customer (Artikal) table, we have to provide the field name as Customer.CustomerID (Artikal.Naziv), it is the way to specify the complex data properties in grid.
itemTemplate.ejGrid({ . . . . . columns: [ . . . . |
contentItem.value.oncollectionchange = function () {
if (itemTemplate.hasClass('e-grid')) { itemTemplate.ejGrid('destroy'); } var first = contentItem.children[0], fieldname = [];
for (i = 0; i < first.children.length; i++) { //Modify the field name generation code from the screen if (first.children[i].children.length) /*check for related entities*/ ej.merge(fieldname, getColumnName(first.children[i])); else fieldname[i] = { field: first.children[i].valueModel.name, width: 50 }; } //Rendering the Grid Control itemTemplate.ejGrid( { dataSource: contentItem.value.data, columns:fieldname }); //Util to auto-generate the columns with complex property field names. function getColumnName(input) { var name = input.name, cols = [], htxt; for (var i = 0, n = name; i < input.children.length;n = name, i++) { n = [n, input.children[i].name].join("."); cols[i] = { field: n, headerText: input.children[i].displayName, width: 50 }; } return cols; |
itemTemplate.ejGrid( toolbarClick: function (args) { case "Delete": contentItem.value.selectedItem = this.getSelectedRecords()[0]; var currentPage = this.model.pageSettings.currentPage; if (!($.isEmptyObject(contentItem.value.selectedItem))) { args.cancel = true; contentItem.value.deleteSelected(); //delete the records in grid myapp.commitChanges().then(function success() { // If success. var grid = $(".e-grid").data("ejGrid"); grid.gotoPage(currentPage); msls.showMessageBox("Delete is successfull.", { title: "Delete" }); } } }); |
4. Now in the grid, to display the CustomerID (Naziv) field from Customer (Artikal) table, we have to provide the field name as Customer.CustomerID (Artikal.Naziv), it is the way to specify the complex data properties in grid.
itemTemplate.ejGrid({ . . . . . columns: [ . . . . |
Also We can use the following method to auto-generate the column name for the related entities.
contentItem.value.oncollectionchange = function () {
if (itemTemplate.hasClass('e-grid')) { itemTemplate.ejGrid('destroy'); } var first = contentItem.children[0], fieldname = [];
for (i = 0; i < first.children.length; i++) { //Modify the field name generation code from the screen if (first.children[i].children.length) /*check for related entities*/ ej.merge(fieldname, getColumnName(first.children[i])); else fieldname[i] = { field: first.children[i].valueModel.name, width: 50 }; } //Rendering the Grid Control itemTemplate.ejGrid( { dataSource: contentItem.value.data, columns:fieldname }); //Util to auto-generate the columns with complex property field names. function getColumnName(input) { var name = input.name, cols = [], htxt; for (var i = 0, n = name; i < input.children.length;n = name, i++) { n = [n, input.children[i].name].join("."); cols[i] = { field: n, headerText: input.children[i].displayName, width: 50 }; } return cols; |
With the above steps, the field name for the related entities will be concatenated with period (.), for example, the CustomerID (Naziv)from Customer (Artikal) entity will be represented as Customer.CustomerID (“Artikal.Naziv”). So that now the grid can bind with the eager loaded related entities properly.
Regards,
Gowthami V.
itemTemplate.ejGrid( toolbarClick: function (args) { case "Delete": contentItem.value.selectedItem = this.getSelectedRecords()[0]; var currentPage = this.model.pageSettings.currentPage; if (!($.isEmptyObject(contentItem.value.selectedItem))) { args.cancel = true; contentItem.value.deleteSelected(); //delete the records in grid myapp.commitChanges().then(function success() { // If success. var grid = $(".e-grid").data("ejGrid"); grid.gotoPage(currentPage); msls.showMessageBox("Delete is successfull.", { title: "Delete" }); } } }); |
5. Now in the grid, to display the CustomerID (Naziv) field from Customer (Artikal) table, we have to provide the field name as Customer.CustomerID (Artikal.Naziv), it is the way to specify the complex data properties in grid.
itemTemplate.ejGrid({ . . . . . columns: [ . . . . |
Also We can use the following method to auto-generate the column name for the related entities.
contentItem.value.oncollectionchange = function () {
if (itemTemplate.hasClass('e-grid')) { itemTemplate.ejGrid('destroy'); } var first = contentItem.children[0], fieldname = [];
for (i = 0; i < first.children.length; i++) { //Modify the field name generation code from the screen if (first.children[i].children.length) /*check for related entities*/ ej.merge(fieldname, getColumnName(first.children[i])); else fieldname[i] = { field: first.children[i].valueModel.name, width: 50 }; } //Rendering the Grid Control itemTemplate.ejGrid( { dataSource: contentItem.value.data, columns:fieldname }); //Util to auto-generate the columns with complex property field names. function getColumnName(input) { var name = input.name, cols = [], htxt; for (var i = 0, n = name; i < input.children.length;n = name, i++) { n = [n, input.children[i].name].join("."); cols[i] = { field: n, headerText: input.children[i].displayName, width: 50 }; } return cols; |
With the above steps, the field name for the related entities will be concatenated with period (.), for example, the CustomerID (Naziv)from Customer (Artikal) entity will be represented as Customer.CustomerID (“Artikal.Naziv”). So that now the grid can bind with the eager loaded related entities properly.
Regards,
Gowthami V.
itemTemplate.ejGrid( toolbarClick: function (args) { case "Delete": contentItem.value.selectedItem = this.getSelectedRecords()[0]; var currentPage = this.model.pageSettings.currentPage; if (!($.isEmptyObject(contentItem.value.selectedItem))) { args.cancel = true; contentItem.value.deleteSelected(); //delete the records in grid myapp.commitChanges().then(function success() { // If success. var grid = $(".e-grid").data("ejGrid"); grid.gotoPage(currentPage); msls.showMessageBox("Delete is successfull.", { title: "Delete" }); } } }); |
5. Now in the grid, to display the CustomerID (Naziv) field from Customer (Artikal) table, we have to provide the field name as Customer.CustomerID (Artikal.Naziv), it is the way to specify the complex data properties in grid.
itemTemplate.ejGrid({ . . . . . columns: [ . . . . |
Also We can use the following method to auto-generate the column name for the related entities.
contentItem.value.oncollectionchange = function () {
if (itemTemplate.hasClass('e-grid')) { itemTemplate.ejGrid('destroy'); } var first = contentItem.children[0], fieldname = [];
for (i = 0; i < first.children.length; i++) { //Modify the field name generation code from the screen if (first.children[i].children.length) /*check for related entities*/ ej.merge(fieldname, getColumnName(first.children[i])); else fieldname[i] = { field: first.children[i].valueModel.name, width: 50 }; } //Rendering the Grid Control itemTemplate.ejGrid( { dataSource: contentItem.value.data, columns:fieldname }); //Util to auto-generate the columns with complex property field names. function getColumnName(input) { var name = input.name, cols = [], htxt; for (var i = 0, n = name; i < input.children.length;n = name, i++) { n = [n, input.children[i].name].join("."); cols[i] = { field: n, headerText: input.children[i].displayName, width: 50 }; } return cols; |
With the above steps, the field name for the related entities will be concatenated with period (.), for example, the CustomerID (Naziv)from Customer (Artikal) entity will be represented as Customer.CustomerID (“Artikal.Naziv”). So that now the grid can bind with the eager loaded related entities properly.
Regards,
Gowthami V.
itemTemplate.ejGrid( toolbarClick: function (args) { case "Delete": contentItem.value.selectedItem = this.getSelectedRecords()[0]; var currentPage = this.model.pageSettings.currentPage; if (!($.isEmptyObject(contentItem.value.selectedItem))) { args.cancel = true; contentItem.value.deleteSelected(); //delete the records in grid myapp.commitChanges().then(function success() { // If success. var grid = $(".e-grid").data("ejGrid"); grid.gotoPage(currentPage); msls.showMessageBox("Delete is successfull.", { title: "Delete" }); } } }); |
5. Now in the grid, to display the CustomerID (Naziv) field from Customer (Artikal) table, we have to provide the field name as Customer.CustomerID (Artikal.Naziv), it is the way to specify the complex data properties in grid.
itemTemplate.ejGrid({ . . . . . columns: [ . . . . |
Also We can use the following method to auto-generate the column name for the related entities.
contentItem.value.oncollectionchange = function () {
if (itemTemplate.hasClass('e-grid')) { itemTemplate.ejGrid('destroy'); } var first = contentItem.children[0], fieldname = [];
for (i = 0; i < first.children.length; i++) { //Modify the field name generation code from the screen if (first.children[i].children.length) /*check for related entities*/ ej.merge(fieldname, getColumnName(first.children[i])); else fieldname[i] = { field: first.children[i].valueModel.name, width: 50 }; } //Rendering the Grid Control itemTemplate.ejGrid( { dataSource: contentItem.value.data, columns:fieldname }); //Util to auto-generate the columns with complex property field names. function getColumnName(input) { var name = input.name, cols = [], htxt; for (var i = 0, n = name; i < input.children.length;n = name, i++) { n = [n, input.children[i].name].join("."); cols[i] = { field: n, headerText: input.children[i].displayName, width: 50 }; } return cols; |
With the above steps, the field name for the related entities will be concatenated with period (.), for example, the CustomerID (Naziv)from Customer (Artikal) entity will be represented as Customer.CustomerID (“Artikal.Naziv”). So that now the grid can bind with the eager loaded related entities properly.
Regards,
Gowthami V.
itemTemplate.ejGrid( { . . . . toolbarClick: function (args) { . . . . . . . . case "Delete": . . . . contentItem.value.selectedItem = dgrid.getSelectedRecords(); . .. . msls.showMessageBox("Delete record? This cannot be undone!", { title: "Delete record?", buttons: msls.MessageBoxButtons.yesNo, defaultResult: msls.MessageBoxResult.no }).then(function (result) { if (result === msls.MessageBoxResult.yes) { if (!($.isEmptyObject(contentItem.value.selectedItem)) && !($.isPlainObject(contentItem.value.selectedItem))) { //delete the records in grid contentItem.value.selectedItem.forEach(function (item) { item.deleteEntity(); //calling the applyChanges after deleting each entity myapp.applyChanges().then( function () { . . . . . . . . . . . . }); }); }); }; } . . . . . . . . }, }); } } |
itemTemplate.ejGrid( { . . . . . . . . toolbarClick: function (args) { var dgrid = this; . . . . . . . . case "Update": . . . . args.cancel = true; this.batchSave(); myapp.applyChanges().then(null, function (errorResponse) { . . . . . . . . }); }); break; }, }); } } |