Editing Remove method with Dialog

Hi,

I am able to Add/Edit data in Dialog mode, but I am unable to Remove. I found from this thread that it is purposefully only sending back the primary key to remove:
https://www.syncfusion.com/forums/139479/grid-16-2-046-with-dialogtemplate-not-updating-parameter-null-but-insert-is-ok

I can see how this would normally be fine, but in my case I have a list of objects in each row and each object has its own id. The primary key being used was created specifically for the grid in order to complete update actions.

Is there a way to send the row data back to the controller when doing a remove?

Thanks!

4 Replies

AG Ajith Govarthan Syncfusion Team September 18, 2020 12:33 PM UTC

Hi Jessica, 

Thanks for contacting Syncfusion support. 

Based on your requirement you want to send complete row data while deleting the row in the grid component and we have also suspect that you have attached a forum which is related to EJ1 platform. So please confirm that you are using EJ1 Grid or EJ2 Grid. 

By default in EJ2 Grid when we delete a row only primarykey will be sent to server side in Normal Edit mode and for batch Edit Mode complete row data will be sent to server side for delete action which is the actual behavior of our EJ2 Grid Component.  

So, please explain the issue that you are facing when we pass only the primaryKey value to the server-side while perform delete operation. If possible, please share the screenshot or video demonstration of an issue. 


Note: In EJ2 Grid the primaryKey value is must to perform CRUD operations. 
 
Regards, 
Ajith G. 



JG Jessica Goodrich October 1, 2020 12:03 AM UTC

I am using EJ2.

For now I have a work around -- creating a composite key as the primary key in the grid.

The problem I have is that one row of data on the user interface (the syncfusion grid) contains multiple rows from the back end database. I do this with a view model. So if I only pass one of the primary keys for deletion, the rest will not get deleted.

I think this would be a nice thing to change in the future.


EM Emiliano October 2, 2020 09:15 AM UTC

I had the same problem as you.


This code solved my problem, but it only works for a single row selection! If you choose other methods of selection, you have to change this.

You have to add the "Load" event to the Grid, and then put this code in the event:

function Load(args) {
     var customAdaptor = new ej.data.UrlAdaptor(); 
     //or
     //var customAdaptor = new ej.data.RemoteSaveAdaptor();

     customAdaptor = ej.base.extend(customAdaptor, {

        remove: function (dm, keyField, value, tableName) {
            var record = this.getSelectedRecords()[0];
            ej.data.JsonAdaptor.prototype.remove(dm, keyField, value);
            return {
                url: dm.dataSource.removeUrl || dm.dataSource.crudUrl || dm.dataSource.url,
                type: 'POST',
                contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                data: $.param(record)
            };
        }
    });

    this.dataSource.adaptor = customAdaptor;
}



PK Prasanna Kumar Viswanathan Syncfusion Team October 6, 2020 12:36 PM UTC

Hi Jessica, 
 
Sorry for the late reply. 
 
As per Emiliano update you can achieve your requirement using the custom adaptor in the Load event. If you face any issue while achieving your requirement please get back to us for further assistance. 
 
Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon